mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Remove deprecated extra flow logic and TLD-specific pricing proxy
This also adds a domain update pricing hook to DomainPricingCustomLogic. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142286755
This commit is contained in:
parent
348cea9d8d
commit
f44557f34f
41 changed files with 494 additions and 1744 deletions
|
@ -21,6 +21,7 @@ import google.registry.flows.SessionMetadata;
|
||||||
import google.registry.flows.domain.DomainPricingLogic;
|
import google.registry.flows.domain.DomainPricingLogic;
|
||||||
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
|
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.eppinput.EppInput;
|
import google.registry.model.eppinput.EppInput;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -36,11 +37,78 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||||
super(eppInput, sessionMetadata);
|
super(eppInput, sessionMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A hook that customizes create price. */
|
/** A hook that customizes the application update price. */
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public FeesAndCredits customizeCreatePrice(CreatePriceParameters createPriceParameters)
|
public FeesAndCredits customizeApplicationUpdatePrice(
|
||||||
|
ApplicationUpdatePriceParameters priceParameters) throws EppException {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A hook that customizes the create price. */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public FeesAndCredits customizeCreatePrice(CreatePriceParameters priceParameters)
|
||||||
throws EppException {
|
throws EppException {
|
||||||
return createPriceParameters.feesAndCredits();
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A hook that customizes the renew price. */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public FeesAndCredits customizeRenewPrice(RenewPriceParameters priceParameters)
|
||||||
|
throws EppException {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A hook that customizes the restore price. */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public FeesAndCredits customizeRestorePrice(RestorePriceParameters priceParameters)
|
||||||
|
throws EppException {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A hook that customizes the transfer price. */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public FeesAndCredits customizeTransferPrice(TransferPriceParameters priceParameters)
|
||||||
|
throws EppException {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A hook that customizes the update price. */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public FeesAndCredits customizeUpdatePrice(UpdatePriceParameters priceParameters)
|
||||||
|
throws EppException {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A class to encapsulate parameters for a call to {@link #customizeApplicationUpdatePrice} . */
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class ApplicationUpdatePriceParameters extends ImmutableObject {
|
||||||
|
|
||||||
|
public abstract FeesAndCredits feesAndCredits();
|
||||||
|
|
||||||
|
public abstract Registry registry();
|
||||||
|
|
||||||
|
public abstract DomainApplication domainApplication();
|
||||||
|
|
||||||
|
public abstract DateTime asOfDate();
|
||||||
|
|
||||||
|
public static Builder newBuilder() {
|
||||||
|
return new AutoValue_DomainPricingCustomLogic_ApplicationUpdatePriceParameters.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for {@link ApplicationUpdatePriceParameters}. */
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits);
|
||||||
|
|
||||||
|
public abstract Builder setRegistry(Registry registry);
|
||||||
|
|
||||||
|
public abstract Builder setDomainApplication(DomainApplication domainApplication);
|
||||||
|
|
||||||
|
public abstract Builder setAsOfDate(DateTime asOfDate);
|
||||||
|
|
||||||
|
public abstract ApplicationUpdatePriceParameters build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A class to encapsulate parameters for a call to {@link #customizeCreatePrice} . */
|
/** A class to encapsulate parameters for a call to {@link #customizeCreatePrice} . */
|
||||||
|
@ -78,4 +146,140 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||||
public abstract CreatePriceParameters build();
|
public abstract CreatePriceParameters build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A class to encapsulate parameters for a call to {@link #customizeRenewPrice} . */
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class RenewPriceParameters extends ImmutableObject {
|
||||||
|
|
||||||
|
public abstract FeesAndCredits feesAndCredits();
|
||||||
|
|
||||||
|
public abstract Registry registry();
|
||||||
|
|
||||||
|
public abstract InternetDomainName domainName();
|
||||||
|
|
||||||
|
public abstract DateTime asOfDate();
|
||||||
|
|
||||||
|
public abstract int years();
|
||||||
|
|
||||||
|
public static Builder newBuilder() {
|
||||||
|
return new AutoValue_DomainPricingCustomLogic_RenewPriceParameters.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for {@link RenewPriceParameters}. */
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits);
|
||||||
|
|
||||||
|
public abstract Builder setRegistry(Registry registry);
|
||||||
|
|
||||||
|
public abstract Builder setDomainName(InternetDomainName domainName);
|
||||||
|
|
||||||
|
public abstract Builder setAsOfDate(DateTime asOfDate);
|
||||||
|
|
||||||
|
public abstract Builder setYears(int years);
|
||||||
|
|
||||||
|
public abstract RenewPriceParameters build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A class to encapsulate parameters for a call to {@link #customizeRestorePrice} . */
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class RestorePriceParameters extends ImmutableObject {
|
||||||
|
|
||||||
|
public abstract FeesAndCredits feesAndCredits();
|
||||||
|
|
||||||
|
public abstract Registry registry();
|
||||||
|
|
||||||
|
public abstract InternetDomainName domainName();
|
||||||
|
|
||||||
|
public abstract DateTime asOfDate();
|
||||||
|
|
||||||
|
public static Builder newBuilder() {
|
||||||
|
return new AutoValue_DomainPricingCustomLogic_RestorePriceParameters.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for {@link RestorePriceParameters}. */
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits);
|
||||||
|
|
||||||
|
public abstract Builder setRegistry(Registry registry);
|
||||||
|
|
||||||
|
public abstract Builder setDomainName(InternetDomainName domainName);
|
||||||
|
|
||||||
|
public abstract Builder setAsOfDate(DateTime asOfDate);
|
||||||
|
|
||||||
|
public abstract RestorePriceParameters build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A class to encapsulate parameters for a call to {@link #customizeTransferPrice} . */
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class TransferPriceParameters extends ImmutableObject {
|
||||||
|
|
||||||
|
public abstract FeesAndCredits feesAndCredits();
|
||||||
|
|
||||||
|
public abstract Registry registry();
|
||||||
|
|
||||||
|
public abstract InternetDomainName domainName();
|
||||||
|
|
||||||
|
public abstract DateTime asOfDate();
|
||||||
|
|
||||||
|
public abstract int years();
|
||||||
|
|
||||||
|
public static Builder newBuilder() {
|
||||||
|
return new AutoValue_DomainPricingCustomLogic_TransferPriceParameters.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for {@link TransferPriceParameters}. */
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits);
|
||||||
|
|
||||||
|
public abstract Builder setRegistry(Registry registry);
|
||||||
|
|
||||||
|
public abstract Builder setDomainName(InternetDomainName domainName);
|
||||||
|
|
||||||
|
public abstract Builder setAsOfDate(DateTime asOfDate);
|
||||||
|
|
||||||
|
public abstract Builder setYears(int years);
|
||||||
|
|
||||||
|
public abstract TransferPriceParameters build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A class to encapsulate parameters for a call to {@link #customizeUpdatePrice} . */
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class UpdatePriceParameters extends ImmutableObject {
|
||||||
|
|
||||||
|
public abstract FeesAndCredits feesAndCredits();
|
||||||
|
|
||||||
|
public abstract Registry registry();
|
||||||
|
|
||||||
|
public abstract InternetDomainName domainName();
|
||||||
|
|
||||||
|
public abstract DateTime asOfDate();
|
||||||
|
|
||||||
|
public static Builder newBuilder() {
|
||||||
|
return new AutoValue_DomainPricingCustomLogic_UpdatePriceParameters.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for {@link UpdatePriceParameters}. */
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits);
|
||||||
|
|
||||||
|
public abstract Builder setRegistry(Registry registry);
|
||||||
|
|
||||||
|
public abstract Builder setDomainName(InternetDomainName domainName);
|
||||||
|
|
||||||
|
public abstract Builder setAsOfDate(DateTime asOfDate);
|
||||||
|
|
||||||
|
public abstract UpdatePriceParameters build();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InternetDomainName;
|
import com.google.common.net.InternetDomainName;
|
||||||
|
@ -177,7 +176,6 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
||||||
.setNameservers(command.getNameservers())
|
.setNameservers(command.getNameservers())
|
||||||
.setContacts(command.getContacts())
|
.setContacts(command.getContacts())
|
||||||
.build();
|
.build();
|
||||||
handleExtraFlowLogic(registry.getTldStr(), years, historyEntry, newDomain, now);
|
|
||||||
entitiesToSave.add(
|
entitiesToSave.add(
|
||||||
newDomain,
|
newDomain,
|
||||||
buildApplicationHistory(application, now),
|
buildApplicationHistory(application, now),
|
||||||
|
@ -363,22 +361,6 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
||||||
&& !matchesAnchorTenantReservation(domainName, authInfoToken);
|
&& !matchesAnchorTenantReservation(domainName, authInfoToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
String tld, int years, HistoryEntry historyEntry, DomainResource newDomain, DateTime now)
|
|
||||||
throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainAllocateLogic(
|
|
||||||
newDomain,
|
|
||||||
clientId,
|
|
||||||
now,
|
|
||||||
years,
|
|
||||||
eppInput,
|
|
||||||
historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enqueueTasks(AllocateCreateExtension allocateCreate, DomainResource newDomain) {
|
private void enqueueTasks(AllocateCreateExtension allocateCreate, DomainResource newDomain) {
|
||||||
if (newDomain.shouldPublishToDns()) {
|
if (newDomain.shouldPublishToDns()) {
|
||||||
DnsQueue.create().addDomainRefreshTask(newDomain.getFullyQualifiedDomainName());
|
DnsQueue.create().addDomainRefreshTask(newDomain.getFullyQualifiedDomainName());
|
||||||
|
|
|
@ -44,7 +44,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -260,8 +259,6 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
|
||||||
.build();
|
.build();
|
||||||
HistoryEntry historyEntry = buildHistory(newApplication.getRepoId(), command.getPeriod(), now);
|
HistoryEntry historyEntry = buildHistory(newApplication.getRepoId(), command.getPeriod(), now);
|
||||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||||
handleExtraFlowLogic(
|
|
||||||
registry.getTldStr(), command.getPeriod().getValue(), historyEntry, newApplication);
|
|
||||||
entitiesToSave.add(
|
entitiesToSave.add(
|
||||||
newApplication,
|
newApplication,
|
||||||
historyEntry,
|
historyEntry,
|
||||||
|
@ -383,21 +380,6 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
|
||||||
return responseExtensionsBuilder.build();
|
return responseExtensionsBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
String tld, int years, HistoryEntry historyEntry, DomainApplication newApplication)
|
|
||||||
throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalApplicationCreateLogic(
|
|
||||||
newApplication,
|
|
||||||
clientId,
|
|
||||||
years,
|
|
||||||
eppInput,
|
|
||||||
historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Landrush applications are disallowed during sunrise. */
|
/** Landrush applications are disallowed during sunrise. */
|
||||||
static class LandrushApplicationDisallowedDuringSunriseException
|
static class LandrushApplicationDisallowedDuringSunriseException
|
||||||
extends RequiredParameterMissingException {
|
extends RequiredParameterMissingException {
|
||||||
|
|
|
@ -108,21 +108,10 @@ public final class DomainApplicationDeleteFlow implements TransactionalFlow {
|
||||||
.setParent(Key.create(existingApplication))
|
.setParent(Key.create(existingApplication))
|
||||||
.build();
|
.build();
|
||||||
updateForeignKeyIndexDeletionTime(newApplication);
|
updateForeignKeyIndexDeletionTime(newApplication);
|
||||||
handleExtraFlowLogic(tld, historyEntry, existingApplication, now);
|
|
||||||
ofy().save().<Object>entities(newApplication, historyEntry);
|
ofy().save().<Object>entities(newApplication, historyEntry);
|
||||||
return responseBuilder.build();
|
return responseBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(String tld, HistoryEntry historyEntry,
|
|
||||||
DomainApplication existingApplication, DateTime now) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalApplicationDeleteLogic(
|
|
||||||
existingApplication, clientId, now, eppInput, historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A sunrise application cannot be deleted during landrush. */
|
/** A sunrise application cannot be deleted during landrush. */
|
||||||
static class SunriseApplicationCannotBeDeletedInLandrushException
|
static class SunriseApplicationCannotBeDeletedInLandrushException
|
||||||
extends StatusProhibitsOperationException {
|
extends StatusProhibitsOperationException {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import google.registry.flows.FlowModule.ClientId;
|
||||||
import google.registry.flows.FlowModule.TargetId;
|
import google.registry.flows.FlowModule.TargetId;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainCommand.Info;
|
import google.registry.model.domain.DomainCommand.Info;
|
||||||
import google.registry.model.domain.flags.FlagsInfoResponseExtension;
|
|
||||||
import google.registry.model.domain.launch.LaunchInfoExtension;
|
import google.registry.model.domain.launch.LaunchInfoExtension;
|
||||||
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
||||||
import google.registry.model.eppcommon.AuthInfo;
|
import google.registry.model.eppcommon.AuthInfo;
|
||||||
|
@ -47,7 +46,6 @@ import google.registry.model.mark.Mark;
|
||||||
import google.registry.model.smd.EncodedSignedMark;
|
import google.registry.model.smd.EncodedSignedMark;
|
||||||
import google.registry.model.smd.SignedMark;
|
import google.registry.model.smd.SignedMark;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
import java.util.Set;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
|
@ -136,16 +134,6 @@ public final class DomainApplicationInfoFlow implements Flow {
|
||||||
.setMarks(marksBuilder.build())
|
.setMarks(marksBuilder.build())
|
||||||
.build());
|
.build());
|
||||||
addSecDnsExtensionIfPresent(extensions, application.getDsData());
|
addSecDnsExtensionIfPresent(extensions, application.getDsData());
|
||||||
// If the TLD uses the flags extension, add it to the info response.
|
|
||||||
Optional<RegistryExtraFlowLogic> extraLogicManager =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(application);
|
|
||||||
if (extraLogicManager.isPresent()) {
|
|
||||||
Set<String> flags = extraLogicManager.get().getApplicationExtensionFlags(
|
|
||||||
application, clientId, now); // As-of date is always now for info commands.
|
|
||||||
if (!flags.isEmpty()) {
|
|
||||||
extensions.add(FlagsInfoResponseExtension.create(ImmutableList.copyOf(flags)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return extensions.build();
|
return extensions.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import google.registry.flows.FlowModule.Superuser;
|
||||||
import google.registry.flows.FlowModule.TargetId;
|
import google.registry.flows.FlowModule.TargetId;
|
||||||
import google.registry.flows.TransactionalFlow;
|
import google.registry.flows.TransactionalFlow;
|
||||||
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException;
|
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException;
|
||||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainCommand.Update;
|
import google.registry.model.domain.DomainCommand.Update;
|
||||||
|
@ -137,6 +137,7 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow {
|
||||||
@Inject @Superuser boolean isSuperuser;
|
@Inject @Superuser boolean isSuperuser;
|
||||||
@Inject HistoryEntry.Builder historyBuilder;
|
@Inject HistoryEntry.Builder historyBuilder;
|
||||||
@Inject EppResponse.Builder responseBuilder;
|
@Inject EppResponse.Builder responseBuilder;
|
||||||
|
@Inject DomainPricingLogic pricingLogic;
|
||||||
@Inject DomainApplicationUpdateFlow() {}
|
@Inject DomainApplicationUpdateFlow() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -160,7 +161,6 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow {
|
||||||
HistoryEntry historyEntry = buildHistory(existingApplication, now);
|
HistoryEntry historyEntry = buildHistory(existingApplication, now);
|
||||||
DomainApplication newApplication = updateApplication(existingApplication, command, now);
|
DomainApplication newApplication = updateApplication(existingApplication, command, now);
|
||||||
validateNewApplication(newApplication);
|
validateNewApplication(newApplication);
|
||||||
handleExtraFlowLogic(newApplication.getTld(), historyEntry, newApplication, now);
|
|
||||||
ofy().save().<ImmutableObject>entities(newApplication, historyEntry);
|
ofy().save().<ImmutableObject>entities(newApplication, historyEntry);
|
||||||
return responseBuilder.build();
|
return responseBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -181,14 +181,14 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow {
|
||||||
throw new ApplicationStatusProhibitsUpdateException(
|
throw new ApplicationStatusProhibitsUpdateException(
|
||||||
existingApplication.getApplicationStatus());
|
existingApplication.getApplicationStatus());
|
||||||
}
|
}
|
||||||
EppCommandOperations commandOperations = TldSpecificLogicProxy.getApplicationUpdatePrice(
|
FeesAndCredits feesAndCredits =
|
||||||
Registry.get(tld), existingApplication, clientId, now, eppInput);
|
pricingLogic.getApplicationUpdatePrice(Registry.get(tld), existingApplication, now);
|
||||||
FeeUpdateCommandExtension feeUpdate =
|
FeeUpdateCommandExtension feeUpdate =
|
||||||
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
||||||
// If the fee extension is present, validate it (even if the cost is zero, to check for price
|
// 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
|
// 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.
|
// it throws an error if the name is premium, and we don't want to do that here.
|
||||||
Money totalCost = commandOperations.getTotalCost();
|
Money totalCost = feesAndCredits.getTotalCost();
|
||||||
if (feeUpdate != null) {
|
if (feeUpdate != null) {
|
||||||
validateFeeChallenge(targetId, tld, now, feeUpdate, totalCost);
|
validateFeeChallenge(targetId, tld, now, feeUpdate, totalCost);
|
||||||
} else if (!totalCost.isZero()) {
|
} else if (!totalCost.isZero()) {
|
||||||
|
@ -248,16 +248,6 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow {
|
||||||
validateNameserversCountForTld(newApplication.getTld(), newApplication.getNameservers().size());
|
validateNameserversCountForTld(newApplication.getTld(), newApplication.getNameservers().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(String tld, HistoryEntry historyEntry,
|
|
||||||
DomainApplication newApplication, DateTime now) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalApplicationUpdateLogic(
|
|
||||||
newApplication, clientId, now, eppInput, historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Application status prohibits this domain update. */
|
/** Application status prohibits this domain update. */
|
||||||
static class ApplicationStatusProhibitsUpdateException extends StatusProhibitsOperationException {
|
static class ApplicationStatusProhibitsUpdateException extends StatusProhibitsOperationException {
|
||||||
public ApplicationStatusProhibitsUpdateException(ApplicationStatus status) {
|
public ApplicationStatusProhibitsUpdateException(ApplicationStatus status) {
|
||||||
|
|
|
@ -206,10 +206,8 @@ public final class DomainCheckFlow implements Flow {
|
||||||
feeCheckItem,
|
feeCheckItem,
|
||||||
builder,
|
builder,
|
||||||
domainNames.get(domainName),
|
domainNames.get(domainName),
|
||||||
clientId,
|
|
||||||
feeCheck.getCurrency(),
|
feeCheck.getCurrency(),
|
||||||
now,
|
now,
|
||||||
eppInput,
|
|
||||||
pricingLogic);
|
pricingLogic);
|
||||||
responseItems.add(builder.setDomainNameIfSupported(domainName).build());
|
responseItems.add(builder.setDomainNameIfSupported(domainName).build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,6 @@ public final class DomainDeleteFlow implements TransactionalFlow {
|
||||||
clientId)))
|
clientId)))
|
||||||
.setDeletePollMessage(Key.create(deletePollMessage));
|
.setDeletePollMessage(Key.create(deletePollMessage));
|
||||||
}
|
}
|
||||||
handleExtraFlowLogic(existingDomain, historyEntry, now);
|
|
||||||
DomainResource newDomain = builder.build();
|
DomainResource newDomain = builder.build();
|
||||||
updateForeignKeyIndexDeletionTime(newDomain);
|
updateForeignKeyIndexDeletionTime(newDomain);
|
||||||
handlePendingTransferOnDelete(existingDomain, newDomain, now, historyEntry);
|
handlePendingTransferOnDelete(existingDomain, newDomain, now, historyEntry);
|
||||||
|
@ -233,17 +232,6 @@ public final class DomainDeleteFlow implements TransactionalFlow {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
DomainResource existingResource, HistoryEntry historyEntry, DateTime now)
|
|
||||||
throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(existingResource);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainDeleteLogic(
|
|
||||||
existingResource, clientId, now, eppInput, historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ImmutableList<FeeTransformResponseExtension> getResponseExtensions(
|
private ImmutableList<FeeTransformResponseExtension> getResponseExtensions(
|
||||||
DomainResource existingDomain, DateTime now) {
|
DomainResource existingDomain, DateTime now) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import static com.google.common.collect.Iterables.concat;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static com.google.common.collect.Sets.union;
|
import static com.google.common.collect.Sets.union;
|
||||||
import static google.registry.flows.EppXmlTransformer.unmarshal;
|
import static google.registry.flows.EppXmlTransformer.unmarshal;
|
||||||
import static google.registry.flows.domain.TldSpecificLogicProxy.getMatchingLrpToken;
|
import static google.registry.flows.domain.DomainPricingLogic.getMatchingLrpToken;
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.registry.Registries.findTldForName;
|
import static google.registry.model.registry.Registries.findTldForName;
|
||||||
|
@ -94,7 +94,6 @@ import google.registry.model.domain.secdns.SecDnsUpdateExtension;
|
||||||
import google.registry.model.domain.secdns.SecDnsUpdateExtension.Add;
|
import google.registry.model.domain.secdns.SecDnsUpdateExtension.Add;
|
||||||
import google.registry.model.domain.secdns.SecDnsUpdateExtension.Remove;
|
import google.registry.model.domain.secdns.SecDnsUpdateExtension.Remove;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.eppinput.EppInput;
|
|
||||||
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.mark.Mark;
|
import google.registry.model.mark.Mark;
|
||||||
|
@ -586,10 +585,8 @@ public class DomainFlowUtils {
|
||||||
FeeQueryCommandExtensionItem feeRequest,
|
FeeQueryCommandExtensionItem feeRequest,
|
||||||
FeeQueryResponseExtensionItem.Builder<?, ?> builder,
|
FeeQueryResponseExtensionItem.Builder<?, ?> builder,
|
||||||
InternetDomainName domain,
|
InternetDomainName domain,
|
||||||
String clientId,
|
|
||||||
@Nullable CurrencyUnit topLevelCurrency,
|
@Nullable CurrencyUnit topLevelCurrency,
|
||||||
DateTime currentDate,
|
DateTime currentDate,
|
||||||
EppInput eppInput,
|
|
||||||
DomainPricingLogic pricingLogic)
|
DomainPricingLogic pricingLogic)
|
||||||
throws EppException {
|
throws EppException {
|
||||||
DateTime now = currentDate;
|
DateTime now = currentDate;
|
||||||
|
@ -617,7 +614,7 @@ public class DomainFlowUtils {
|
||||||
.setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase())
|
.setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase())
|
||||||
.setCurrencyIfSupported(registry.getCurrency())
|
.setCurrencyIfSupported(registry.getCurrency())
|
||||||
.setPeriod(feeRequest.getPeriod())
|
.setPeriod(feeRequest.getPeriod())
|
||||||
.setClass(TldSpecificLogicProxy.getFeeClass(domainNameString, now).orNull());
|
.setClass(pricingLogic.getFeeClass(domainNameString, now).orNull());
|
||||||
|
|
||||||
ImmutableList<Fee> fees = ImmutableList.of();
|
ImmutableList<Fee> fees = ImmutableList.of();
|
||||||
switch (feeRequest.getCommandName()) {
|
switch (feeRequest.getCommandName()) {
|
||||||
|
@ -633,26 +630,22 @@ public class DomainFlowUtils {
|
||||||
break;
|
break;
|
||||||
case RENEW:
|
case RENEW:
|
||||||
builder.setAvailIfSupported(true);
|
builder.setAvailIfSupported(true);
|
||||||
fees = TldSpecificLogicProxy.getRenewPrice(
|
fees = pricingLogic.getRenewPrice(registry, domainNameString, now, years).getFees();
|
||||||
registry, domainNameString, clientId, now, years, eppInput).getFees();
|
|
||||||
break;
|
break;
|
||||||
case RESTORE:
|
case RESTORE:
|
||||||
if (years != 1) {
|
if (years != 1) {
|
||||||
throw new RestoresAreAlwaysForOneYearException();
|
throw new RestoresAreAlwaysForOneYearException();
|
||||||
}
|
}
|
||||||
builder.setAvailIfSupported(true);
|
builder.setAvailIfSupported(true);
|
||||||
fees = TldSpecificLogicProxy.getRestorePrice(
|
fees = pricingLogic.getRestorePrice(registry, domainNameString, now).getFees();
|
||||||
registry, domainNameString, clientId, now, eppInput).getFees();
|
|
||||||
break;
|
break;
|
||||||
case TRANSFER:
|
case TRANSFER:
|
||||||
builder.setAvailIfSupported(true);
|
builder.setAvailIfSupported(true);
|
||||||
fees = TldSpecificLogicProxy.getTransferPrice(
|
fees = pricingLogic.getTransferPrice(registry, domainNameString, now, years).getFees();
|
||||||
registry, domainNameString, clientId, now, years, eppInput).getFees();
|
|
||||||
break;
|
break;
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
builder.setAvailIfSupported(true);
|
builder.setAvailIfSupported(true);
|
||||||
fees = TldSpecificLogicProxy.getUpdatePrice(
|
fees = pricingLogic.getUpdatePrice(registry, domainNameString, now).getFees();
|
||||||
registry, domainNameString, clientId, now, eppInput).getFees();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new UnknownFeeCommandException(feeRequest.getUnparsedCommandName());
|
throw new UnknownFeeCommandException(feeRequest.getUnparsedCommandName());
|
||||||
|
|
|
@ -39,7 +39,6 @@ import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.DomainResource.Builder;
|
import google.registry.model.domain.DomainResource.Builder;
|
||||||
import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06;
|
import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06;
|
||||||
import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06;
|
import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06;
|
||||||
import google.registry.model.domain.flags.FlagsInfoResponseExtension;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.domain.rgp.RgpInfoExtension;
|
import google.registry.model.domain.rgp.RgpInfoExtension;
|
||||||
import google.registry.model.eppcommon.AuthInfo;
|
import google.registry.model.eppcommon.AuthInfo;
|
||||||
|
@ -48,7 +47,6 @@ import google.registry.model.eppinput.ResourceCommand;
|
||||||
import google.registry.model.eppoutput.EppResponse;
|
import google.registry.model.eppoutput.EppResponse;
|
||||||
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
import java.util.Set;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
|
@ -149,26 +147,11 @@ public final class DomainInfoFlow implements Flow {
|
||||||
feeInfo,
|
feeInfo,
|
||||||
builder,
|
builder,
|
||||||
InternetDomainName.from(targetId),
|
InternetDomainName.from(targetId),
|
||||||
clientId,
|
|
||||||
null,
|
null,
|
||||||
now,
|
now,
|
||||||
eppInput,
|
|
||||||
pricingLogic);
|
pricingLogic);
|
||||||
extensions.add(builder.build());
|
extensions.add(builder.build());
|
||||||
}
|
}
|
||||||
// If the TLD uses the flags extension, add it to the info response.
|
|
||||||
Optional<RegistryExtraFlowLogic> extraLogicManager =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(domain);
|
|
||||||
if (extraLogicManager.isPresent()) {
|
|
||||||
Set<String> flags =
|
|
||||||
extraLogicManager
|
|
||||||
.get()
|
|
||||||
.getExtensionFlags(
|
|
||||||
domain, clientId, now); // As-of date is always now for info commands.
|
|
||||||
if (!flags.isEmpty()) {
|
|
||||||
extensions.add(FlagsInfoResponseExtension.create(ImmutableList.copyOf(flags)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return extensions.build();
|
return extensions.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package google.registry.flows.domain;
|
package google.registry.flows.domain;
|
||||||
|
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
import static com.google.common.collect.Iterables.concat;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
|
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
|
||||||
import static google.registry.pricing.PricingEngineProxy.getDomainFeeClass;
|
import static google.registry.pricing.PricingEngineProxy.getDomainFeeClass;
|
||||||
|
@ -28,20 +28,21 @@ import com.google.common.net.InternetDomainName;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.FlowScope;
|
import google.registry.flows.FlowScope;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
|
||||||
import google.registry.flows.custom.DomainPricingCustomLogic;
|
import google.registry.flows.custom.DomainPricingCustomLogic;
|
||||||
|
import google.registry.flows.custom.DomainPricingCustomLogic.ApplicationUpdatePriceParameters;
|
||||||
import google.registry.flows.custom.DomainPricingCustomLogic.CreatePriceParameters;
|
import google.registry.flows.custom.DomainPricingCustomLogic.CreatePriceParameters;
|
||||||
|
import google.registry.flows.custom.DomainPricingCustomLogic.RenewPriceParameters;
|
||||||
|
import google.registry.flows.custom.DomainPricingCustomLogic.RestorePriceParameters;
|
||||||
|
import google.registry.flows.custom.DomainPricingCustomLogic.TransferPriceParameters;
|
||||||
|
import google.registry.flows.custom.DomainPricingCustomLogic.UpdatePriceParameters;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainResource;
|
|
||||||
import google.registry.model.domain.LrpTokenEntity;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.domain.fee.BaseFee;
|
import google.registry.model.domain.fee.BaseFee;
|
||||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
import google.registry.model.domain.fee.BaseFee.FeeType;
|
||||||
import google.registry.model.domain.fee.Credit;
|
import google.registry.model.domain.fee.Credit;
|
||||||
import google.registry.model.domain.fee.Fee;
|
import google.registry.model.domain.fee.Fee;
|
||||||
import google.registry.model.eppinput.EppInput;
|
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.joda.money.CurrencyUnit;
|
import org.joda.money.CurrencyUnit;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
|
@ -62,11 +63,12 @@ public final class DomainPricingLogic {
|
||||||
|
|
||||||
/** A collection of fees and credits for a specific EPP transform. */
|
/** A collection of fees and credits for a specific EPP transform. */
|
||||||
public static final class FeesAndCredits extends ImmutableObject {
|
public static final class FeesAndCredits extends ImmutableObject {
|
||||||
|
|
||||||
private final CurrencyUnit currency;
|
private final CurrencyUnit currency;
|
||||||
private final ImmutableList<Fee> fees;
|
private final ImmutableList<Fee> fees;
|
||||||
private final ImmutableList<Credit> credits;
|
private final ImmutableList<Credit> credits;
|
||||||
|
|
||||||
/** Constructs an FeesAndCredits object. The arguments are sorted into fees and credits. */
|
/** Constructs a new instance. The currency must be the same across all fees and credits. */
|
||||||
public FeesAndCredits(CurrencyUnit currency, BaseFee... baseFees) {
|
public FeesAndCredits(CurrencyUnit currency, BaseFee... baseFees) {
|
||||||
this.currency = checkArgumentNotNull(currency, "Currency may not be null in FeesAndCredits.");
|
this.currency = checkArgumentNotNull(currency, "Currency may not be null in FeesAndCredits.");
|
||||||
ImmutableList.Builder<Fee> feeBuilder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<Fee> feeBuilder = new ImmutableList.Builder<>();
|
||||||
|
@ -121,14 +123,19 @@ public final class DomainPricingLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the list of credits for the event. */
|
/** Returns the list of credits for the event. */
|
||||||
public List<Credit> getCredits() {
|
public ImmutableList<Credit> getCredits() {
|
||||||
return nullToEmpty(credits);
|
return ImmutableList.copyOf(nullToEmpty(credits));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the currency for all fees in the event. */
|
/** Returns the currency for all fees in the event. */
|
||||||
public final CurrencyUnit getCurrency() {
|
public final CurrencyUnit getCurrency() {
|
||||||
return currency;
|
return currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns all fees and credits for the event. */
|
||||||
|
public ImmutableList<BaseFee> getFeesAndCredits() {
|
||||||
|
return ImmutableList.copyOf(concat(getFees(), getCredits()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a new create price for the Pricer. */
|
/** Returns a new create price for the Pricer. */
|
||||||
|
@ -164,121 +171,97 @@ public final class DomainPricingLogic {
|
||||||
|
|
||||||
// TODO: (b/33000134) clean up the rest of the pricing calls.
|
// TODO: (b/33000134) clean up the rest of the pricing calls.
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes the renew fee or credit. This is called by other methods which use the renew fee
|
|
||||||
* (renew, restore, etc).
|
|
||||||
*/
|
|
||||||
static BaseFee getRenewFeeOrCredit(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput)
|
|
||||||
throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
// TODO: Consider changing the method definition to have the domain passed in to begin with.
|
|
||||||
DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date);
|
|
||||||
if (domain == null) {
|
|
||||||
throw new ResourceDoesNotExistException(DomainResource.class, domainName);
|
|
||||||
}
|
|
||||||
return extraFlowLogic.get().getRenewFeeOrCredit(domain, clientId, date, years, eppInput);
|
|
||||||
} else {
|
|
||||||
return Fee.create(getDomainRenewCost(domainName, date, years).getAmount(), FeeType.RENEW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a new renew price for the pricer. */
|
/** Returns a new renew price for the pricer. */
|
||||||
public static FeesAndCredits getRenewPrice(
|
@SuppressWarnings("unused")
|
||||||
|
public FeesAndCredits getRenewPrice(
|
||||||
Registry registry,
|
Registry registry,
|
||||||
String domainName,
|
String domainName,
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
DateTime date,
|
||||||
int years,
|
int years)
|
||||||
EppInput eppInput)
|
|
||||||
throws EppException {
|
throws EppException {
|
||||||
return new FeesAndCredits(
|
Money renewCost = getDomainRenewCost(domainName, date, years);
|
||||||
registry.getCurrency(),
|
return customLogic.customizeRenewPrice(
|
||||||
getRenewFeeOrCredit(registry, domainName, clientId, date, years, eppInput));
|
RenewPriceParameters.newBuilder()
|
||||||
|
.setFeesAndCredits(
|
||||||
|
new FeesAndCredits(
|
||||||
|
registry.getCurrency(), Fee.create(renewCost.getAmount(), FeeType.RENEW)))
|
||||||
|
.setRegistry(registry)
|
||||||
|
.setDomainName(InternetDomainName.from(domainName))
|
||||||
|
.setAsOfDate(date)
|
||||||
|
.setYears(years)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a new restore price for the pricer. */
|
/** Returns a new restore price for the pricer. */
|
||||||
public static FeesAndCredits getRestorePrice(
|
@SuppressWarnings("unused")
|
||||||
Registry registry, String domainName, String clientId, DateTime date, EppInput eppInput)
|
public FeesAndCredits getRestorePrice(Registry registry, String domainName, DateTime date)
|
||||||
throws EppException {
|
throws EppException {
|
||||||
return new FeesAndCredits(
|
FeesAndCredits feesAndCredits =
|
||||||
registry.getCurrency(),
|
new FeesAndCredits(
|
||||||
getRenewFeeOrCredit(registry, domainName, clientId, date, 1, eppInput),
|
registry.getCurrency(),
|
||||||
Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE));
|
Fee.create(getDomainRenewCost(domainName, date, 1).getAmount(), FeeType.RENEW),
|
||||||
|
Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE));
|
||||||
|
return customLogic.customizeRestorePrice(
|
||||||
|
RestorePriceParameters.newBuilder()
|
||||||
|
.setFeesAndCredits(feesAndCredits)
|
||||||
|
.setRegistry(registry)
|
||||||
|
.setDomainName(InternetDomainName.from(domainName))
|
||||||
|
.setAsOfDate(date)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a new transfer price for the pricer. */
|
/** Returns a new transfer price for the pricer. */
|
||||||
public static FeesAndCredits getTransferPrice(
|
public FeesAndCredits getTransferPrice(
|
||||||
Registry registry,
|
Registry registry,
|
||||||
String domainName,
|
String domainName,
|
||||||
String clientId,
|
|
||||||
DateTime transferDate,
|
DateTime transferDate,
|
||||||
int years,
|
int years)
|
||||||
EppInput eppInput)
|
|
||||||
throws EppException {
|
throws EppException {
|
||||||
// Currently, all transfer prices = renew prices, so just pass through.
|
Money renewCost = getDomainRenewCost(domainName, transferDate, years);
|
||||||
return getRenewPrice(registry, domainName, clientId, transferDate, years, eppInput);
|
return customLogic.customizeTransferPrice(
|
||||||
|
TransferPriceParameters.newBuilder()
|
||||||
|
.setFeesAndCredits(
|
||||||
|
new FeesAndCredits(
|
||||||
|
registry.getCurrency(), Fee.create(renewCost.getAmount(), FeeType.RENEW)))
|
||||||
|
.setRegistry(registry)
|
||||||
|
.setDomainName(InternetDomainName.from(domainName))
|
||||||
|
.setAsOfDate(transferDate)
|
||||||
|
.setYears(years)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a new update price for the pricer. */
|
/** Returns a new update price for the pricer. */
|
||||||
public static FeesAndCredits getUpdatePrice(
|
public FeesAndCredits getUpdatePrice(Registry registry, String domainName, DateTime date)
|
||||||
Registry registry, String domainName, String clientId, DateTime date, EppInput eppInput)
|
|
||||||
throws EppException {
|
throws EppException {
|
||||||
CurrencyUnit currency = registry.getCurrency();
|
CurrencyUnit currency = registry.getCurrency();
|
||||||
|
BaseFee feeOrCredit =
|
||||||
// If there is extra flow logic, it may specify an update price. Otherwise, there is none.
|
Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
|
||||||
BaseFee feeOrCredit;
|
return customLogic.customizeUpdatePrice(
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
UpdatePriceParameters.newBuilder()
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
.setFeesAndCredits(new FeesAndCredits(currency, feeOrCredit))
|
||||||
if (extraFlowLogic.isPresent()) {
|
.setRegistry(registry)
|
||||||
// TODO: Consider changing the method definition to have the domain passed in to begin with.
|
.setDomainName(InternetDomainName.from(domainName))
|
||||||
DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date);
|
.setAsOfDate(date)
|
||||||
if (domain == null) {
|
.build());
|
||||||
throw new ResourceDoesNotExistException(DomainResource.class, domainName);
|
|
||||||
}
|
|
||||||
feeOrCredit = extraFlowLogic.get().getUpdateFeeOrCredit(domain, clientId, date, eppInput);
|
|
||||||
} else {
|
|
||||||
feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new FeesAndCredits(currency, feeOrCredit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a new domain application update price for the pricer. */
|
/** Returns a new domain application update price for the pricer. */
|
||||||
public static FeesAndCredits getApplicationUpdatePrice(
|
@SuppressWarnings("unused")
|
||||||
Registry registry,
|
public FeesAndCredits getApplicationUpdatePrice(
|
||||||
DomainApplication application,
|
Registry registry, DomainApplication application, DateTime date) throws EppException {
|
||||||
String clientId,
|
BaseFee feeOrCredit =
|
||||||
DateTime date,
|
Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
|
||||||
EppInput eppInput)
|
return customLogic.customizeApplicationUpdatePrice(
|
||||||
throws EppException {
|
ApplicationUpdatePriceParameters.newBuilder()
|
||||||
CurrencyUnit currency = registry.getCurrency();
|
.setFeesAndCredits(new FeesAndCredits(registry.getCurrency(), feeOrCredit))
|
||||||
|
.setRegistry(registry)
|
||||||
// If there is extra flow logic, it may specify an update price. Otherwise, there is none.
|
.setDomainApplication(application)
|
||||||
BaseFee feeOrCredit;
|
.setAsOfDate(date)
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
.build());
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
feeOrCredit =
|
|
||||||
extraFlowLogic
|
|
||||||
.get()
|
|
||||||
.getApplicationUpdateFeeOrCredit(application, clientId, date, eppInput);
|
|
||||||
} else {
|
|
||||||
feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new FeesAndCredits(currency, feeOrCredit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the fee class for a given domain and date. */
|
/** Returns the fee class for a given domain and date. */
|
||||||
public static Optional<String> getFeeClass(String domainName, DateTime date) {
|
public Optional<String> getFeeClass(String domainName, DateTime date) {
|
||||||
return getDomainFeeClass(domainName, date);
|
return getDomainFeeClass(domainName, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponsePar
|
||||||
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponseReturnData;
|
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponseReturnData;
|
||||||
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeSaveParameters;
|
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeSaveParameters;
|
||||||
import google.registry.flows.custom.EntityChanges;
|
import google.registry.flows.custom.EntityChanges;
|
||||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
import google.registry.model.billing.BillingEvent.OneTime;
|
import google.registry.model.billing.BillingEvent.OneTime;
|
||||||
|
@ -121,6 +121,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
@Inject HistoryEntry.Builder historyBuilder;
|
@Inject HistoryEntry.Builder historyBuilder;
|
||||||
@Inject EppResponse.Builder responseBuilder;
|
@Inject EppResponse.Builder responseBuilder;
|
||||||
@Inject DomainRenewFlowCustomLogic customLogic;
|
@Inject DomainRenewFlowCustomLogic customLogic;
|
||||||
|
@Inject DomainPricingLogic pricingLogic;
|
||||||
@Inject DomainRenewFlow() {}
|
@Inject DomainRenewFlow() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -137,10 +138,10 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
int years = command.getPeriod().getValue();
|
int years = command.getPeriod().getValue();
|
||||||
FeeRenewCommandExtension feeRenew =
|
FeeRenewCommandExtension feeRenew =
|
||||||
eppInput.getSingleExtension(FeeRenewCommandExtension.class);
|
eppInput.getSingleExtension(FeeRenewCommandExtension.class);
|
||||||
EppCommandOperations commandOperations = TldSpecificLogicProxy.getRenewPrice(
|
FeesAndCredits feesAndCredits =
|
||||||
Registry.get(existingDomain.getTld()), targetId, clientId, now, years, eppInput);
|
pricingLogic.getRenewPrice(Registry.get(existingDomain.getTld()), targetId, now, years);
|
||||||
validateFeeChallenge(
|
validateFeeChallenge(
|
||||||
targetId, existingDomain.getTld(), now, feeRenew, commandOperations.getTotalCost());
|
targetId, existingDomain.getTld(), now, feeRenew, feesAndCredits.getTotalCost());
|
||||||
customLogic.afterValidation(
|
customLogic.afterValidation(
|
||||||
AfterValidationParameters.newBuilder()
|
AfterValidationParameters.newBuilder()
|
||||||
.setExistingDomain(existingDomain)
|
.setExistingDomain(existingDomain)
|
||||||
|
@ -161,7 +162,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
String tld = existingDomain.getTld();
|
String tld = existingDomain.getTld();
|
||||||
// Bill for this explicit renew itself.
|
// Bill for this explicit renew itself.
|
||||||
BillingEvent.OneTime explicitRenewEvent =
|
BillingEvent.OneTime explicitRenewEvent =
|
||||||
createRenewBillingEvent(tld, commandOperations.getTotalCost(), years, historyEntry, now);
|
createRenewBillingEvent(tld, feesAndCredits.getTotalCost(), years, historyEntry, now);
|
||||||
// Create a new autorenew billing event and poll message starting at the new expiration time.
|
// Create a new autorenew billing event and poll message starting at the new expiration time.
|
||||||
BillingEvent.Recurring newAutorenewEvent = newAutorenewBillingEvent(existingDomain)
|
BillingEvent.Recurring newAutorenewEvent = newAutorenewBillingEvent(existingDomain)
|
||||||
.setEventTime(newExpirationTime)
|
.setEventTime(newExpirationTime)
|
||||||
|
@ -173,13 +174,6 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
.build();
|
.build();
|
||||||
// End the old autorenew billing event and poll message now. This may delete the poll message.
|
// End the old autorenew billing event and poll message now. This may delete the poll message.
|
||||||
updateAutorenewRecurrenceEndTime(existingDomain, now);
|
updateAutorenewRecurrenceEndTime(existingDomain, now);
|
||||||
// Handle extra flow logic, if any.
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainRenewLogic(
|
|
||||||
existingDomain, clientId, now, years, eppInput, historyEntry);
|
|
||||||
}
|
|
||||||
DomainResource newDomain = existingDomain.asBuilder()
|
DomainResource newDomain = existingDomain.asBuilder()
|
||||||
.setRegistrationExpirationTime(newExpirationTime)
|
.setRegistrationExpirationTime(newExpirationTime)
|
||||||
.setAutorenewBillingEvent(Key.create(newAutorenewEvent))
|
.setAutorenewBillingEvent(Key.create(newAutorenewEvent))
|
||||||
|
@ -212,7 +206,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
.setDomain(newDomain)
|
.setDomain(newDomain)
|
||||||
.setResData(DomainRenewData.create(targetId, newExpirationTime))
|
.setResData(DomainRenewData.create(targetId, newExpirationTime))
|
||||||
.setResponseExtensions(
|
.setResponseExtensions(
|
||||||
createResponseExtensions(commandOperations.getTotalCost(), feeRenew))
|
createResponseExtensions(feesAndCredits.getTotalCost(), feeRenew))
|
||||||
.build());
|
.build());
|
||||||
return responseBuilder
|
return responseBuilder
|
||||||
.setResData(responseData.resData())
|
.setResData(responseData.resData())
|
||||||
|
|
|
@ -42,7 +42,7 @@ import google.registry.flows.FlowModule.ClientId;
|
||||||
import google.registry.flows.FlowModule.Superuser;
|
import google.registry.flows.FlowModule.Superuser;
|
||||||
import google.registry.flows.FlowModule.TargetId;
|
import google.registry.flows.FlowModule.TargetId;
|
||||||
import google.registry.flows.TransactionalFlow;
|
import google.registry.flows.TransactionalFlow;
|
||||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
import google.registry.model.billing.BillingEvent.OneTime;
|
import google.registry.model.billing.BillingEvent.OneTime;
|
||||||
|
@ -114,6 +114,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
|
||||||
@Inject HistoryEntry.Builder historyBuilder;
|
@Inject HistoryEntry.Builder historyBuilder;
|
||||||
@Inject DnsQueue dnsQueue;
|
@Inject DnsQueue dnsQueue;
|
||||||
@Inject EppResponse.Builder responseBuilder;
|
@Inject EppResponse.Builder responseBuilder;
|
||||||
|
@Inject DomainPricingLogic pricingLogic;
|
||||||
@Inject DomainRestoreRequestFlow() {}
|
@Inject DomainRestoreRequestFlow() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,11 +129,11 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
|
||||||
DateTime now = ofy().getTransactionTime();
|
DateTime now = ofy().getTransactionTime();
|
||||||
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now);
|
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now);
|
||||||
Money restoreCost = Registry.get(existingDomain.getTld()).getStandardRestoreCost();
|
Money restoreCost = Registry.get(existingDomain.getTld()).getStandardRestoreCost();
|
||||||
EppCommandOperations renewCommandOperations = TldSpecificLogicProxy.getRenewPrice(
|
FeesAndCredits feesAndCredits =
|
||||||
Registry.get(existingDomain.getTld()), targetId, clientId, now, 1, eppInput);
|
pricingLogic.getRenewPrice(Registry.get(existingDomain.getTld()), targetId, now, 1);
|
||||||
FeeUpdateCommandExtension feeUpdate =
|
FeeUpdateCommandExtension feeUpdate =
|
||||||
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
||||||
Money totalCost = renewCommandOperations.getTotalCost();
|
Money totalCost = feesAndCredits.getTotalCost();
|
||||||
verifyRestoreAllowed(command, existingDomain, restoreCost, totalCost, feeUpdate, now);
|
verifyRestoreAllowed(command, existingDomain, restoreCost, totalCost, feeUpdate, now);
|
||||||
HistoryEntry historyEntry = buildHistory(existingDomain, now);
|
HistoryEntry historyEntry = buildHistory(existingDomain, now);
|
||||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||||
|
@ -153,13 +154,6 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
|
||||||
.setAutorenewEndTime(END_OF_TIME)
|
.setAutorenewEndTime(END_OF_TIME)
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
.build();
|
.build();
|
||||||
// Handle extra flow logic, if any.
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainRestoreLogic(
|
|
||||||
existingDomain, clientId, now, eppInput, historyEntry);
|
|
||||||
}
|
|
||||||
DomainResource newDomain =
|
DomainResource newDomain =
|
||||||
performRestore(existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage);
|
performRestore(existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage);
|
||||||
updateForeignKeyIndexDeletionTime(newDomain);
|
updateForeignKeyIndexDeletionTime(newDomain);
|
||||||
|
|
|
@ -177,7 +177,6 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
|
||||||
newDomain.getTransferData(),
|
newDomain.getTransferData(),
|
||||||
newExpirationTime,
|
newExpirationTime,
|
||||||
historyEntry);
|
historyEntry);
|
||||||
handleExtraFlowLogic(tld, historyEntry, newDomain);
|
|
||||||
ofy().save().<ImmutableObject>entities(
|
ofy().save().<ImmutableObject>entities(
|
||||||
newDomain,
|
newDomain,
|
||||||
historyEntry,
|
historyEntry,
|
||||||
|
@ -193,16 +192,4 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
|
||||||
targetId, newDomain.getTransferData(), newDomain.getRegistrationExpirationTime()))
|
targetId, newDomain.getTransferData(), newDomain.getRegistrationExpirationTime()))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
String tld, HistoryEntry historyEntry, DomainResource newDomain) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainTransferApproveLogic(
|
|
||||||
newDomain,
|
|
||||||
clientId,
|
|
||||||
historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,6 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
|
||||||
.build();
|
.build();
|
||||||
DomainResource newDomain =
|
DomainResource newDomain =
|
||||||
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now);
|
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now);
|
||||||
handleExtraFlowLogic(existingDomain.getTld(), historyEntry, existingDomain);
|
|
||||||
ofy().save().<ImmutableObject>entities(
|
ofy().save().<ImmutableObject>entities(
|
||||||
newDomain,
|
newDomain,
|
||||||
historyEntry,
|
historyEntry,
|
||||||
|
@ -108,16 +107,4 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
|
||||||
.setResData(createTransferResponse(targetId, newDomain.getTransferData(), null))
|
.setResData(createTransferResponse(targetId, newDomain.getTransferData(), null))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
String tld, HistoryEntry historyEntry, DomainResource existingDomain) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainTransferCancelLogic(
|
|
||||||
existingDomain,
|
|
||||||
clientId,
|
|
||||||
historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,6 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
|
||||||
checkAllowedAccessToTld(clientId, existingDomain.getTld());
|
checkAllowedAccessToTld(clientId, existingDomain.getTld());
|
||||||
DomainResource newDomain =
|
DomainResource newDomain =
|
||||||
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now);
|
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now);
|
||||||
handleExtraFlowLogic(existingDomain.getTld(), historyEntry, existingDomain);
|
|
||||||
ofy().save().<ImmutableObject>entities(
|
ofy().save().<ImmutableObject>entities(
|
||||||
newDomain,
|
newDomain,
|
||||||
historyEntry,
|
historyEntry,
|
||||||
|
@ -106,16 +105,4 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
|
||||||
.setResData(createTransferResponse(targetId, newDomain.getTransferData(), null))
|
.setResData(createTransferResponse(targetId, newDomain.getTransferData(), null))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
String tld, HistoryEntry historyEntry, DomainResource existingDomain) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainTransferRejectLogic(
|
|
||||||
existingDomain,
|
|
||||||
clientId,
|
|
||||||
historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
|
||||||
// cloneProjectedAtTime() will replace these old autorenew entities with the server approve ones
|
// cloneProjectedAtTime() will replace these old autorenew entities with the server approve ones
|
||||||
// that we've created in this flow and stored in pendingTransferData.
|
// that we've created in this flow and stored in pendingTransferData.
|
||||||
updateAutorenewRecurrenceEndTime(existingDomain, automaticTransferTime);
|
updateAutorenewRecurrenceEndTime(existingDomain, automaticTransferTime);
|
||||||
handleExtraFlowLogic(years, existingDomain, historyEntry, now);
|
|
||||||
DomainResource newDomain = existingDomain.asBuilder()
|
DomainResource newDomain = existingDomain.asBuilder()
|
||||||
.setTransferData(pendingTransferData)
|
.setTransferData(pendingTransferData)
|
||||||
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
||||||
|
@ -376,22 +375,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
int years, DomainResource existingDomain, HistoryEntry historyEntry, DateTime now)
|
|
||||||
throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainTransferRequestLogic(
|
|
||||||
existingDomain,
|
|
||||||
gainingClientId,
|
|
||||||
now,
|
|
||||||
years,
|
|
||||||
eppInput,
|
|
||||||
historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DomainTransferResponse createResponse(
|
private DomainTransferResponse createResponse(
|
||||||
Period period, DomainResource existingDomain, DomainResource newDomain, DateTime now) {
|
Period period, DomainResource existingDomain, DomainResource newDomain, DateTime now) {
|
||||||
// If the registration were approved this instant, this is what the new expiration would be,
|
// If the registration were approved this instant, this is what the new expiration would be,
|
||||||
|
|
|
@ -56,7 +56,7 @@ import google.registry.flows.custom.DomainUpdateFlowCustomLogic.AfterValidationP
|
||||||
import google.registry.flows.custom.DomainUpdateFlowCustomLogic.BeforeSaveParameters;
|
import google.registry.flows.custom.DomainUpdateFlowCustomLogic.BeforeSaveParameters;
|
||||||
import google.registry.flows.custom.EntityChanges;
|
import google.registry.flows.custom.EntityChanges;
|
||||||
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException;
|
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException;
|
||||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
import google.registry.model.billing.BillingEvent.Reason;
|
import google.registry.model.billing.BillingEvent.Reason;
|
||||||
|
@ -146,7 +146,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
||||||
@Inject DnsQueue dnsQueue;
|
@Inject DnsQueue dnsQueue;
|
||||||
@Inject EppResponse.Builder responseBuilder;
|
@Inject EppResponse.Builder responseBuilder;
|
||||||
@Inject DomainUpdateFlowCustomLogic customLogic;
|
@Inject DomainUpdateFlowCustomLogic customLogic;
|
||||||
|
@Inject DomainPricingLogic pricingLogic;
|
||||||
@Inject DomainUpdateFlow() {}
|
@Inject DomainUpdateFlow() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -179,7 +179,6 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
||||||
}
|
}
|
||||||
validateNewState(newDomain);
|
validateNewState(newDomain);
|
||||||
dnsQueue.addDomainRefreshTask(targetId);
|
dnsQueue.addDomainRefreshTask(targetId);
|
||||||
handleExtraFlowLogic(existingDomain, historyEntry, now);
|
|
||||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||||
entitiesToSave.add(newDomain, historyEntry);
|
entitiesToSave.add(newDomain, historyEntry);
|
||||||
Optional<BillingEvent.OneTime> statusUpdateBillingEvent =
|
Optional<BillingEvent.OneTime> statusUpdateBillingEvent =
|
||||||
|
@ -214,15 +213,13 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
||||||
}
|
}
|
||||||
String tld = existingDomain.getTld();
|
String tld = existingDomain.getTld();
|
||||||
checkAllowedAccessToTld(clientId, tld);
|
checkAllowedAccessToTld(clientId, tld);
|
||||||
EppCommandOperations commandOperations = TldSpecificLogicProxy.getUpdatePrice(
|
|
||||||
Registry.get(tld), targetId, clientId, now, eppInput);
|
|
||||||
|
|
||||||
FeeTransformCommandExtension feeUpdate =
|
FeeTransformCommandExtension feeUpdate =
|
||||||
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
||||||
// If the fee extension is present, validate it (even if the cost is zero, to check for price
|
// 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
|
// 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.
|
// it throws an error if the name is premium, and we don't want to do that here.
|
||||||
Money totalCost = commandOperations.getTotalCost();
|
FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(Registry.get(tld), targetId, now);
|
||||||
|
Money totalCost = feesAndCredits.getTotalCost();
|
||||||
if (feeUpdate != null) {
|
if (feeUpdate != null) {
|
||||||
validateFeeChallenge(targetId, existingDomain.getTld(), now, feeUpdate, totalCost);
|
validateFeeChallenge(targetId, existingDomain.getTld(), now, feeUpdate, totalCost);
|
||||||
} else if (!totalCost.isZero()) {
|
} else if (!totalCost.isZero()) {
|
||||||
|
@ -352,14 +349,4 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
||||||
}
|
}
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExtraFlowLogic(
|
|
||||||
DomainResource existingDomain, HistoryEntry historyEntry, DateTime now) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain);
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
extraFlowLogic.get().performAdditionalDomainUpdateLogic(
|
|
||||||
existingDomain, clientId, now, eppInput, historyEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,171 +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.flows.domain;
|
|
||||||
|
|
||||||
import google.registry.flows.EppException;
|
|
||||||
import google.registry.model.domain.DomainApplication;
|
|
||||||
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.Set;
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for classes which provide extra registry logic for things like TLD-specific rules and
|
|
||||||
* discounts.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface RegistryExtraFlowLogic {
|
|
||||||
|
|
||||||
/** Gets the flags to be returned for application info commands. */
|
|
||||||
public Set<String> getApplicationExtensionFlags(
|
|
||||||
DomainApplication application, String clientId, DateTime asOfDate);
|
|
||||||
|
|
||||||
/** Gets the flags to be returned for domain info commands. */
|
|
||||||
public Set<String> getExtensionFlags(
|
|
||||||
DomainResource domainResource, String clientId, DateTime asOfDate);
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an application create command. */
|
|
||||||
public void performAdditionalApplicationCreateLogic(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an application delete command. */
|
|
||||||
public void performAdditionalApplicationDeleteLogic(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Computes the expected application update fee. */
|
|
||||||
public BaseFee getApplicationUpdateFeeOrCredit(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an application update command. */
|
|
||||||
public void performAdditionalApplicationUpdateLogic(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an allocate command. */
|
|
||||||
public void performAdditionalDomainAllocateLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Computes the expected creation fee. */
|
|
||||||
public BaseFee getCreateFeeOrCredit(
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a create command. */
|
|
||||||
public void performAdditionalDomainCreateLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a delete command. */
|
|
||||||
public void performAdditionalDomainDeleteLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Computes the expected renewal fee. */
|
|
||||||
public BaseFee getRenewFeeOrCredit(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a renew command. */
|
|
||||||
public void performAdditionalDomainRenewLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a restore command. */
|
|
||||||
public void performAdditionalDomainRestoreLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a domain transfer approve command. */
|
|
||||||
public void performAdditionalDomainTransferApproveLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a domain transfer cancel command. */
|
|
||||||
public void performAdditionalDomainTransferCancelLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a domain transfer reject command. */
|
|
||||||
public void performAdditionalDomainTransferRejectLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a transfer request command. */
|
|
||||||
public void performAdditionalDomainTransferRequestLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
|
|
||||||
/** Computes the expected update fee. */
|
|
||||||
public BaseFee getUpdateFeeOrCredit(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput) throws EppException;
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an update command. */
|
|
||||||
public void performAdditionalDomainUpdateLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException;
|
|
||||||
}
|
|
|
@ -1,64 +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.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.
|
|
||||||
* Eventually, this will probably be replaced with dependency injection, barring unforeseen
|
|
||||||
* complications.
|
|
||||||
*/
|
|
||||||
public class RegistryExtraFlowLogicProxy {
|
|
||||||
|
|
||||||
private static final HashMap<String, Class<? extends RegistryExtraFlowLogic>>
|
|
||||||
extraLogicOverrideMap = new HashMap<>();
|
|
||||||
|
|
||||||
public static void setOverride(
|
|
||||||
String tld, Class<? extends RegistryExtraFlowLogic> extraLogicClass) {
|
|
||||||
if (Registry.get(tld) == null) {
|
|
||||||
throw new IllegalArgumentException(tld + " does not exist");
|
|
||||||
}
|
|
||||||
extraLogicOverrideMap.put(tld, extraLogicClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
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).getConstructor().newInstance());
|
|
||||||
} catch (ReflectiveOperationException ex) {
|
|
||||||
throw new CommandFailedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,314 +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.flows.domain;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
|
||||||
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
|
|
||||||
import static google.registry.pricing.PricingEngineProxy.getDomainFeeClass;
|
|
||||||
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
|
|
||||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.net.InternetDomainName;
|
|
||||||
import com.googlecode.objectify.Key;
|
|
||||||
import google.registry.flows.EppException;
|
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
|
||||||
import google.registry.model.ImmutableObject;
|
|
||||||
import google.registry.model.domain.DomainApplication;
|
|
||||||
import google.registry.model.domain.DomainResource;
|
|
||||||
import google.registry.model.domain.LrpTokenEntity;
|
|
||||||
import google.registry.model.domain.fee.BaseFee;
|
|
||||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
|
||||||
import google.registry.model.domain.fee.Credit;
|
|
||||||
import google.registry.model.domain.fee.Fee;
|
|
||||||
import google.registry.model.eppinput.EppInput;
|
|
||||||
import google.registry.model.registry.Registry;
|
|
||||||
import java.util.List;
|
|
||||||
import org.joda.money.CurrencyUnit;
|
|
||||||
import org.joda.money.Money;
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides pricing, billing, and update logic, with call-outs that can be customized by providing
|
|
||||||
* implementations on a per-TLD basis.
|
|
||||||
*/
|
|
||||||
public final class TldSpecificLogicProxy {
|
|
||||||
/** A collection of fees and credits for a specific EPP transform. */
|
|
||||||
public static final class EppCommandOperations extends ImmutableObject {
|
|
||||||
private final CurrencyUnit currency;
|
|
||||||
private final ImmutableList<Fee> fees;
|
|
||||||
private final ImmutableList<Credit> credits;
|
|
||||||
|
|
||||||
/** Constructs an EppCommandOperations object using separate lists of fees and credits. */
|
|
||||||
EppCommandOperations(
|
|
||||||
CurrencyUnit currency, ImmutableList<Fee> fees, ImmutableList<Credit> credits) {
|
|
||||||
this.currency = checkArgumentNotNull(
|
|
||||||
currency, "Currency may not be null in EppCommandOperations.");
|
|
||||||
checkArgument(!fees.isEmpty(), "You must specify one or more fees.");
|
|
||||||
this.fees = checkArgumentNotNull(fees, "Fees may not be null in EppCommandOperations.");
|
|
||||||
this.credits =
|
|
||||||
checkArgumentNotNull(credits, "Credits may not be null in EppCommandOperations.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an EppCommandOperations object. The arguments are sorted into fees and credits.
|
|
||||||
*/
|
|
||||||
EppCommandOperations(CurrencyUnit currency, BaseFee... feesAndCredits) {
|
|
||||||
this.currency = checkArgumentNotNull(
|
|
||||||
currency, "Currency may not be null in EppCommandOperations.");
|
|
||||||
ImmutableList.Builder<Fee> feeBuilder = new ImmutableList.Builder<>();
|
|
||||||
ImmutableList.Builder<Credit> creditBuilder = new ImmutableList.Builder<>();
|
|
||||||
for (BaseFee feeOrCredit : feesAndCredits) {
|
|
||||||
if (feeOrCredit instanceof Credit) {
|
|
||||||
creditBuilder.add((Credit) feeOrCredit);
|
|
||||||
} else {
|
|
||||||
feeBuilder.add((Fee) feeOrCredit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.fees = feeBuilder.build();
|
|
||||||
this.credits = creditBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Money getTotalCostForType(FeeType type) {
|
|
||||||
Money result = Money.zero(currency);
|
|
||||||
checkArgumentNotNull(type);
|
|
||||||
for (Fee fee : fees) {
|
|
||||||
if (fee.getType() == type) {
|
|
||||||
result = result.plus(fee.getCost());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the total cost of all fees and credits for the event. */
|
|
||||||
public Money getTotalCost() {
|
|
||||||
Money result = Money.zero(currency);
|
|
||||||
for (Fee fee : fees) {
|
|
||||||
result = result.plus(fee.getCost());
|
|
||||||
}
|
|
||||||
for (Credit credit : credits) {
|
|
||||||
result = result.plus(credit.getCost());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the create cost for the event. */
|
|
||||||
public Money getCreateCost() {
|
|
||||||
return getTotalCostForType(FeeType.CREATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the EAP cost for the event. */
|
|
||||||
public Money getEapCost() {
|
|
||||||
return getTotalCostForType(FeeType.EAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the list of fees for the event. */
|
|
||||||
public ImmutableList<Fee> getFees() {
|
|
||||||
return fees;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the list of credits for the event. */
|
|
||||||
public List<Credit> getCredits() {
|
|
||||||
return nullToEmpty(credits);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the currency for all fees in the event. */
|
|
||||||
public final CurrencyUnit getCurrency() {
|
|
||||||
return currency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TldSpecificLogicProxy() {}
|
|
||||||
|
|
||||||
/** Returns a new create price for the Pricer. */
|
|
||||||
public static EppCommandOperations getCreatePrice(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
CurrencyUnit currency = registry.getCurrency();
|
|
||||||
|
|
||||||
// Get the create cost, either from the extra flow logic or straight from PricingEngineProxy.
|
|
||||||
BaseFee createFeeOrCredit;
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
createFeeOrCredit = extraFlowLogic.get()
|
|
||||||
.getCreateFeeOrCredit(domainName, clientId, date, years, eppInput);
|
|
||||||
} else {
|
|
||||||
createFeeOrCredit =
|
|
||||||
Fee.create(getDomainCreateCost(domainName, date, years).getAmount(), FeeType.CREATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create fees for the cost and the EAP fee, if any.
|
|
||||||
Fee eapFee = registry.getEapFeeFor(date);
|
|
||||||
if (!eapFee.hasZeroCost()) {
|
|
||||||
return new EppCommandOperations(currency, createFeeOrCredit, eapFee);
|
|
||||||
} else {
|
|
||||||
return new EppCommandOperations(currency, createFeeOrCredit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes the renew fee or credit. This is called by other methods which use the renew fee
|
|
||||||
* (renew, restore, etc).
|
|
||||||
*/
|
|
||||||
static BaseFee getRenewFeeOrCredit(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
// TODO: Consider changing the method definition to have the domain passed in to begin with.
|
|
||||||
DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date);
|
|
||||||
if (domain == null) {
|
|
||||||
throw new ResourceDoesNotExistException(DomainResource.class, domainName);
|
|
||||||
}
|
|
||||||
return
|
|
||||||
extraFlowLogic.get().getRenewFeeOrCredit(domain, clientId, date, years, eppInput);
|
|
||||||
} else {
|
|
||||||
return Fee.create(getDomainRenewCost(domainName, date, years).getAmount(), FeeType.RENEW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a new renew price for the pricer. */
|
|
||||||
public static EppCommandOperations getRenewPrice(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
return new EppCommandOperations(
|
|
||||||
registry.getCurrency(),
|
|
||||||
getRenewFeeOrCredit(registry, domainName, clientId, date, years, eppInput));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a new restore price for the pricer. */
|
|
||||||
public static EppCommandOperations getRestorePrice(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
return new EppCommandOperations(
|
|
||||||
registry.getCurrency(),
|
|
||||||
getRenewFeeOrCredit(registry, domainName, clientId, date, 1, eppInput),
|
|
||||||
Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a new transfer price for the pricer. */
|
|
||||||
public static EppCommandOperations getTransferPrice(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime transferDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
// Currently, all transfer prices = renew prices, so just pass through.
|
|
||||||
return getRenewPrice(
|
|
||||||
registry, domainName, clientId, transferDate, years, eppInput);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a new update price for the pricer. */
|
|
||||||
public static EppCommandOperations getUpdatePrice(
|
|
||||||
Registry registry,
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
CurrencyUnit currency = registry.getCurrency();
|
|
||||||
|
|
||||||
// If there is extra flow logic, it may specify an update price. Otherwise, there is none.
|
|
||||||
BaseFee feeOrCredit;
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
// TODO: Consider changing the method definition to have the domain passed in to begin with.
|
|
||||||
DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date);
|
|
||||||
if (domain == null) {
|
|
||||||
throw new ResourceDoesNotExistException(DomainResource.class, domainName);
|
|
||||||
}
|
|
||||||
feeOrCredit =
|
|
||||||
extraFlowLogic.get().getUpdateFeeOrCredit(domain, clientId, date, eppInput);
|
|
||||||
} else {
|
|
||||||
feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EppCommandOperations(currency, feeOrCredit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a new domain application update price for the pricer. */
|
|
||||||
public static EppCommandOperations getApplicationUpdatePrice(
|
|
||||||
Registry registry,
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime date,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
CurrencyUnit currency = registry.getCurrency();
|
|
||||||
|
|
||||||
// If there is extra flow logic, it may specify an update price. Otherwise, there is none.
|
|
||||||
BaseFee feeOrCredit;
|
|
||||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
|
||||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
|
||||||
if (extraFlowLogic.isPresent()) {
|
|
||||||
feeOrCredit = extraFlowLogic.get()
|
|
||||||
.getApplicationUpdateFeeOrCredit(application, clientId, date, eppInput);
|
|
||||||
} else {
|
|
||||||
feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EppCommandOperations(currency, feeOrCredit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the fee class for a given domain and date. */
|
|
||||||
public static Optional<String> getFeeClass(String domainName, DateTime date) {
|
|
||||||
return getDomainFeeClass(domainName, date);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether an LRP token String maps to a valid {@link LrpTokenEntity} for the domain name's
|
|
||||||
* TLD, and return that entity (wrapped in an {@link Optional}) if one exists.
|
|
||||||
*
|
|
||||||
* <p>This method has no knowledge of whether or not an auth code (interpreted here as an LRP
|
|
||||||
* token) has already been checked against the reserved list for QLP (anchor tenant), as auth
|
|
||||||
* codes are used for both types of registrations.
|
|
||||||
*/
|
|
||||||
public static Optional<LrpTokenEntity> getMatchingLrpToken(
|
|
||||||
String lrpToken, InternetDomainName domainName) {
|
|
||||||
// Note that until the actual per-TLD logic is built out, what's being done here is a basic
|
|
||||||
// domain-name-to-assignee match.
|
|
||||||
if (!lrpToken.isEmpty()) {
|
|
||||||
LrpTokenEntity token = ofy().load().key(Key.create(LrpTokenEntity.class, lrpToken)).now();
|
|
||||||
if (token != null
|
|
||||||
&& token.getAssignee().equalsIgnoreCase(domainName.toString())
|
|
||||||
&& token.getRedemptionHistoryEntry() == null
|
|
||||||
&& token.getValidTlds().contains(domainName.parent().toString())) {
|
|
||||||
return Optional.of(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.<LrpTokenEntity>absent();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,6 +15,8 @@
|
||||||
package google.registry.flows.custom;
|
package google.registry.flows.custom;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.collect.Iterables.toArray;
|
||||||
|
import static java.math.BigDecimal.TEN;
|
||||||
|
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -61,13 +63,12 @@ public class TestDomainPricingCustomLogic extends DomainPricingCustomLogic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A hook that customizes create price. */
|
|
||||||
@Override
|
@Override
|
||||||
public FeesAndCredits customizeCreatePrice(CreatePriceParameters createPriceParameters)
|
public FeesAndCredits customizeCreatePrice(CreatePriceParameters priceParameters)
|
||||||
throws EppException {
|
throws EppException {
|
||||||
InternetDomainName domainName = createPriceParameters.domainName();
|
InternetDomainName domainName = priceParameters.domainName();
|
||||||
if (domainName.parent().toString().equals("flags")) {
|
if (domainName.parent().toString().equals("flags")) {
|
||||||
FeesAndCredits feesAndCredits = createPriceParameters.feesAndCredits();
|
FeesAndCredits feesAndCredits = priceParameters.feesAndCredits();
|
||||||
ImmutableList.Builder<BaseFee> baseFeeBuilder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<BaseFee> baseFeeBuilder = new ImmutableList.Builder<>();
|
||||||
baseFeeBuilder.addAll(feesAndCredits.getCredits());
|
baseFeeBuilder.addAll(feesAndCredits.getCredits());
|
||||||
for (BaseFee fee : feesAndCredits.getFees()) {
|
for (BaseFee fee : feesAndCredits.getFees()) {
|
||||||
|
@ -77,7 +78,40 @@ public class TestDomainPricingCustomLogic extends DomainPricingCustomLogic {
|
||||||
return new FeesAndCredits(
|
return new FeesAndCredits(
|
||||||
feesAndCredits.getCurrency(), Iterables.toArray(baseFeeBuilder.build(), BaseFee.class));
|
feesAndCredits.getCurrency(), Iterables.toArray(baseFeeBuilder.build(), BaseFee.class));
|
||||||
} else {
|
} else {
|
||||||
return createPriceParameters.feesAndCredits();
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeesAndCredits customizeRenewPrice(RenewPriceParameters priceParameters)
|
||||||
|
throws EppException {
|
||||||
|
if (priceParameters.domainName().toString().startsWith("costly-renew")) {
|
||||||
|
FeesAndCredits feesAndCredits = priceParameters.feesAndCredits();
|
||||||
|
List<BaseFee> newFeesAndCredits =
|
||||||
|
new ImmutableList.Builder<BaseFee>()
|
||||||
|
.addAll(feesAndCredits.getFeesAndCredits())
|
||||||
|
.add(Fee.create(BigDecimal.valueOf(100), FeeType.RENEW))
|
||||||
|
.build();
|
||||||
|
return new FeesAndCredits(
|
||||||
|
feesAndCredits.getCurrency(), toArray(newFeesAndCredits, BaseFee.class));
|
||||||
|
} else {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeesAndCredits customizeUpdatePrice(UpdatePriceParameters priceParameters) {
|
||||||
|
if (priceParameters.domainName().toString().startsWith("non-free-update")) {
|
||||||
|
FeesAndCredits feesAndCredits = priceParameters.feesAndCredits();
|
||||||
|
List<BaseFee> newFeesAndCredits =
|
||||||
|
new ImmutableList.Builder<BaseFee>()
|
||||||
|
.addAll(feesAndCredits.getFeesAndCredits())
|
||||||
|
.add(Fee.create(TEN, FeeType.UPDATE))
|
||||||
|
.build();
|
||||||
|
return new FeesAndCredits(
|
||||||
|
feesAndCredits.getCurrency(), toArray(newFeesAndCredits, BaseFee.class));
|
||||||
|
} else {
|
||||||
|
return priceParameters.feesAndCredits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,6 @@ import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
||||||
import google.registry.model.domain.launch.LaunchNotice;
|
import google.registry.model.domain.launch.LaunchNotice;
|
||||||
|
@ -491,15 +489,4 @@ public class DomainAllocateFlowTest
|
||||||
thrown.expect(OnlySuperuserCanAllocateException.class);
|
thrown.expect(OnlySuperuserCanAllocateException.class);
|
||||||
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_extra() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_allocate.xml",
|
|
||||||
ImmutableMap.of("APPLICATIONID", "2-EXTRA", "DOMAIN", "domain.extra"));
|
|
||||||
setupDomainApplication("extra", TldState.QUIET_PERIOD);
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "allocated");
|
|
||||||
runFlowAsSuperuser();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,6 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.launch.LaunchPhase;
|
import google.registry.model.domain.launch.LaunchPhase;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
|
@ -62,7 +60,6 @@ public class DomainApplicationDeleteFlowTest
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
createTld("tld", TldState.SUNRUSH);
|
createTld("tld", TldState.SUNRUSH);
|
||||||
createTld("extra", TldState.LANDRUSH);
|
createTld("extra", TldState.LANDRUSH);
|
||||||
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doSuccessfulTest() throws Exception {
|
public void doSuccessfulTest() throws Exception {
|
||||||
|
@ -306,17 +303,4 @@ public class DomainApplicationDeleteFlowTest
|
||||||
thrown.expect(ApplicationDomainNameMismatchException.class);
|
thrown.expect(ApplicationDomainNameMismatchException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_extraLogic() throws Exception {
|
|
||||||
persistResource(newDomainApplication("example.extra")
|
|
||||||
.asBuilder()
|
|
||||||
.setRepoId("1-TLD")
|
|
||||||
.setPhase(LaunchPhase.LANDRUSH)
|
|
||||||
.build());
|
|
||||||
setEppInput(
|
|
||||||
"domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.extra"));
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "application deleted");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.domain.DesignatedContact.Type;
|
import google.registry.model.domain.DesignatedContact.Type;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||||
import google.registry.model.domain.launch.LaunchPhase;
|
import google.registry.model.domain.launch.LaunchPhase;
|
||||||
|
@ -71,9 +70,6 @@ public class DomainApplicationInfoFlowTest
|
||||||
setEppInput("domain_info_sunrise.xml");
|
setEppInput("domain_info_sunrise.xml");
|
||||||
sessionMetadata.setClientId("NewRegistrar");
|
sessionMetadata.setClientId("NewRegistrar");
|
||||||
createTld("tld", TldState.SUNRUSH);
|
createTld("tld", TldState.SUNRUSH);
|
||||||
createTld("flags", TldState.SUNRUSH);
|
|
||||||
// For flags extension tests.
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistTestEntities(HostsState hostsState, MarksState marksState) throws Exception {
|
private void persistTestEntities(HostsState hostsState, MarksState marksState) throws Exception {
|
||||||
|
@ -110,33 +106,6 @@ public class DomainApplicationInfoFlowTest
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistFlagsTestEntities(String domainName, HostsState hostsState) throws Exception {
|
|
||||||
registrant = persistActiveContact("jd1234");
|
|
||||||
contact = persistActiveContact("sh8013");
|
|
||||||
host1 = persistActiveHost("ns1.example.net");
|
|
||||||
host2 = persistActiveHost("ns1.example.tld");
|
|
||||||
application = persistResource(new DomainApplication.Builder()
|
|
||||||
.setRepoId("123-TLD")
|
|
||||||
.setFullyQualifiedDomainName(domainName)
|
|
||||||
.setPhase(LaunchPhase.SUNRUSH)
|
|
||||||
.setCurrentSponsorClientId("NewRegistrar")
|
|
||||||
.setCreationClientId("TheRegistrar")
|
|
||||||
.setLastEppUpdateClientId("NewRegistrar")
|
|
||||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
|
||||||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
|
||||||
.setRegistrant(Key.create(registrant))
|
|
||||||
.setContacts(ImmutableSet.of(
|
|
||||||
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
|
||||||
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
|
||||||
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
|
|
||||||
Key.create(host1), Key.create(host2)) : null)
|
|
||||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
|
||||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
|
||||||
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
|
||||||
.setEncodedSignedMarks(null)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState)
|
private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
assertTransactionalFlow(false);
|
assertTransactionalFlow(false);
|
||||||
|
@ -348,21 +317,4 @@ public class DomainApplicationInfoFlowTest
|
||||||
thrown.expect(ApplicationLaunchPhaseMismatchException.class);
|
thrown.expect(ApplicationLaunchPhaseMismatchException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Test registry extra logic manager with no flags. */
|
|
||||||
@Test
|
|
||||||
public void testExtraLogicManager_noFlags() throws Exception {
|
|
||||||
setEppInput("domain_info_sunrise_flags_none.xml");
|
|
||||||
persistFlagsTestEntities("domain.flags", HostsState.NO_HOSTS_EXIST);
|
|
||||||
doSuccessfulTest("domain_info_response_sunrise_flags_none.xml", HostsState.NO_HOSTS_EXIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Test registry extra logic manager with two flags. */
|
|
||||||
@Test
|
|
||||||
public void testExtraLogicManager_twoFlags() throws Exception {
|
|
||||||
setEppInput("domain_info_sunrise_flags_two.xml");
|
|
||||||
persistFlagsTestEntities("domain-flag1-flag2.flags", HostsState.NO_HOSTS_EXIST);
|
|
||||||
doSuccessfulTest("domain_info_response_sunrise_flags_two.xml", HostsState.NO_HOSTS_EXIST);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,6 @@ import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.domain.DesignatedContact.Type;
|
import google.registry.model.domain.DesignatedContact.Type;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainApplication.Builder;
|
import google.registry.model.domain.DomainApplication.Builder;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -94,7 +92,6 @@ public class DomainApplicationUpdateFlowTest
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
createTld("tld", TldState.SUNRUSH);
|
createTld("tld", TldState.SUNRUSH);
|
||||||
createTld("flags", TldState.SUNRISE);
|
createTld("flags", TldState.SUNRISE);
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistReferencedEntities() {
|
private void persistReferencedEntities() {
|
||||||
|
@ -685,15 +682,4 @@ public class DomainApplicationUpdateFlowTest
|
||||||
thrown.expect(FeesMismatchException.class);
|
thrown.expect(FeesMismatchException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_flags() throws Exception {
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistResource(
|
|
||||||
newDomainApplication("update-42.flags").asBuilder().setRepoId("1-ROID").build());
|
|
||||||
setEppInput("domain_update_sunrise_flags.xml", ImmutableMap.of("FEE", "42"));
|
|
||||||
clock.advanceOneMilli();
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "add:flag1;remove:flag2");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,6 @@ import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -107,7 +105,6 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
public void initDomainTest() throws Exception {
|
public void initDomainTest() throws Exception {
|
||||||
createTlds("tld", "flags");
|
createTlds("tld", "flags");
|
||||||
// For flags extension tests.
|
// For flags extension tests.
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupSuccessfulTest() throws Exception {
|
private void setupSuccessfulTest() throws Exception {
|
||||||
|
@ -735,12 +732,4 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
thrown.expect(OnlyToolCanPassMetadataException.class);
|
thrown.expect(OnlyToolCanPassMetadataException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_flags() throws Exception {
|
|
||||||
setEppInput("domain_delete_flags.xml");
|
|
||||||
setupSuccessfulTest();
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "deleted");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.flows.domain;
|
||||||
import static com.google.common.io.BaseEncoding.base16;
|
import static com.google.common.io.BaseEncoding.base16;
|
||||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
|
@ -42,7 +41,6 @@ import google.registry.model.domain.DesignatedContact.Type;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||||
|
@ -68,11 +66,9 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
||||||
setEppInput("domain_info.xml");
|
setEppInput("domain_info.xml");
|
||||||
sessionMetadata.setClientId("NewRegistrar");
|
sessionMetadata.setClientId("NewRegistrar");
|
||||||
clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z"));
|
clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z"));
|
||||||
createTlds("tld", "flags");
|
createTld("tld");
|
||||||
persistResource(
|
persistResource(
|
||||||
AppEngineRule.makeRegistrar1().asBuilder().setClientId("ClientZ").build());
|
AppEngineRule.makeRegistrar1().asBuilder().setClientId("ClientZ").build());
|
||||||
// For flags extension tests.
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistTestEntities(String domainName, boolean inactive) {
|
private void persistTestEntities(String domainName, boolean inactive) {
|
||||||
|
@ -616,20 +612,4 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
||||||
thrown.expect(RestoresAreAlwaysForOneYearException.class);
|
thrown.expect(RestoresAreAlwaysForOneYearException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test registry extra logic manager with no flags. */
|
|
||||||
@Test
|
|
||||||
public void testExtraLogicManager_noFlags() throws Exception {
|
|
||||||
setEppInput("domain_info_flags_none.xml");
|
|
||||||
persistTestEntities("domain.flags", false);
|
|
||||||
doSuccessfulTest("domain_info_response_flags_none.xml", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Test registry extra logic manager with two flags. */
|
|
||||||
@Test
|
|
||||||
public void testExtraLogicManager_twoFlags() throws Exception {
|
|
||||||
setEppInput("domain_info_flags_two.xml");
|
|
||||||
persistTestEntities("domain-flag1-flag2.flags", false);
|
|
||||||
doSuccessfulTest("domain_info_response_flags_two.xml", false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWit
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||||
|
@ -54,8 +53,6 @@ import google.registry.model.billing.BillingEvent.Flag;
|
||||||
import google.registry.model.billing.BillingEvent.Reason;
|
import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
|
@ -88,9 +85,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initDomainTest() {
|
public void initDomainTest() {
|
||||||
createTlds("tld", "flags");
|
createTld("tld");
|
||||||
// For flags extension tests.
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistDomain(StatusValue... statusValues) throws Exception {
|
private void persistDomain(StatusValue... statusValues) throws Exception {
|
||||||
|
@ -131,10 +126,22 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
private void doSuccessfulTest(String responseFilename, int renewalYears) throws Exception {
|
private void doSuccessfulTest(String responseFilename, int renewalYears) throws Exception {
|
||||||
doSuccessfulTest(responseFilename, renewalYears, ImmutableMap.<String, String>of());
|
doSuccessfulTest(responseFilename, renewalYears, ImmutableMap.<String, String>of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doSuccessfulTest(
|
||||||
|
String responseFilename, int renewalYears, Map<String, String> substitutions)
|
||||||
|
throws Exception {
|
||||||
|
doSuccessfulTest(
|
||||||
|
responseFilename,
|
||||||
|
renewalYears,
|
||||||
|
substitutions,
|
||||||
|
Money.of(USD, 11).multipliedBy(renewalYears));
|
||||||
|
}
|
||||||
|
|
||||||
private void doSuccessfulTest(
|
private void doSuccessfulTest(
|
||||||
String responseFilename,
|
String responseFilename,
|
||||||
int renewalYears,
|
int renewalYears,
|
||||||
Map<String, String> substitutions) throws Exception {
|
Map<String, String> substitutions,
|
||||||
|
Money totalRenewCost) throws Exception {
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime();
|
DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime();
|
||||||
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
|
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
|
||||||
|
@ -155,7 +162,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
.setReason(Reason.RENEW)
|
.setReason(Reason.RENEW)
|
||||||
.setTargetId(getUniqueIdFromCommand())
|
.setTargetId(getUniqueIdFromCommand())
|
||||||
.setClientId("TheRegistrar")
|
.setClientId("TheRegistrar")
|
||||||
.setCost(Money.of(USD, 11).multipliedBy(renewalYears))
|
.setCost(totalRenewCost)
|
||||||
.setPeriodYears(renewalYears)
|
.setPeriodYears(renewalYears)
|
||||||
.setEventTime(clock.nowUtc())
|
.setEventTime(clock.nowUtc())
|
||||||
.setBillingTime(clock.nowUtc().plus(Registry.get("tld").getRenewGracePeriodLength()))
|
.setBillingTime(clock.nowUtc().plus(Registry.get("tld").getRenewGracePeriodLength()))
|
||||||
|
@ -215,6 +222,27 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
doSuccessfulTest("domain_renew_response.xml", 5);
|
doSuccessfulTest("domain_renew_response.xml", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess_customLogicFee() throws Exception {
|
||||||
|
// The "costly-renew" domain has an additional RENEW fee of 100 from custom logic on top of the
|
||||||
|
// normal $11 standard renew price for this TLD.
|
||||||
|
setEppInput(
|
||||||
|
"domain_renew_fee_wildcard.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "costly-renew.tld", "FEE_VERSION", "0.6", "AMOUNT", "111.00"));
|
||||||
|
persistDomain();
|
||||||
|
doSuccessfulTest(
|
||||||
|
"domain_renew_response_fee_wildcard.xml",
|
||||||
|
1,
|
||||||
|
new ImmutableMap.Builder<String, String>()
|
||||||
|
.put("DOMAIN", "costly-renew.tld")
|
||||||
|
.put("FEE_VERSION", "0.6")
|
||||||
|
.put("FEE_NS", "fee")
|
||||||
|
.put("AMOUNT", "111.00")
|
||||||
|
.put("EX_DATE", "2001-04-03T22:00:00.000Z")
|
||||||
|
.build(),
|
||||||
|
Money.of(USD, 111));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_fee_v06() throws Exception {
|
public void testSuccess_fee_v06() throws Exception {
|
||||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||||
|
@ -612,23 +640,4 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
thrown.expect(FeesRequiredForPremiumNameException.class);
|
thrown.expect(FeesRequiredForPremiumNameException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFailure_flags_feeMismatch() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_renew_flags.xml", ImmutableMap.of("DOMAIN", "renew-42.flags", "FEE", "11"));
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(FeesMismatchException.class);
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_flags() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_renew_flags.xml", ImmutableMap.of("DOMAIN", "renew-42.flags", "FEE", "42"));
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "renewed");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,6 @@ import google.registry.model.billing.BillingEvent.Flag;
|
||||||
import google.registry.model.billing.BillingEvent.Reason;
|
import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
|
@ -87,8 +85,6 @@ public class DomainRestoreRequestFlowTest extends
|
||||||
@Before
|
@Before
|
||||||
public void initDomainTest() {
|
public void initDomainTest() {
|
||||||
createTlds("tld", "flags");
|
createTlds("tld", "flags");
|
||||||
// For flags extension tests.
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void persistPendingDeleteDomain() throws Exception {
|
void persistPendingDeleteDomain() throws Exception {
|
||||||
|
@ -562,16 +558,4 @@ public class DomainRestoreRequestFlowTest extends
|
||||||
thrown.expect(FeesMismatchException.class);
|
thrown.expect(FeesMismatchException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_flagsWithCorrectFee() throws Exception {
|
|
||||||
// The total cost should be the renewal cost of 42 (set in the XML file) plus the restore cost
|
|
||||||
// of 17 (set in the test registry).
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_restore_request_flags.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "renew-42.flags", "FEE", "59"));
|
|
||||||
persistPendingDeleteDomain();
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "restored");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,6 @@ import google.registry.model.contact.ContactAuthInfo;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -96,7 +94,6 @@ public class DomainTransferApproveFlowTest
|
||||||
.build());
|
.build());
|
||||||
setClientIdForFlow("TheRegistrar");
|
setClientIdForFlow("TheRegistrar");
|
||||||
createTld("extra");
|
createTld("extra");
|
||||||
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
|
||||||
setupDomainWithPendingTransfer();
|
setupDomainWithPendingTransfer();
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
}
|
}
|
||||||
|
@ -494,12 +491,4 @@ public class DomainTransferApproveFlowTest
|
||||||
|
|
||||||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||||
// entering pending delete phase. So it's already handled in that test case.
|
// entering pending delete phase. So it's already handled in that test case.
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_extra() throws Exception {
|
|
||||||
setupDomainWithPendingTransfer("extra");
|
|
||||||
clock.advanceOneMilli();
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "transfer approved");
|
|
||||||
doFailingTest("domain_transfer_approve_extra.xml");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ import google.registry.model.contact.ContactAuthInfo;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
|
@ -299,13 +297,4 @@ public class DomainTransferCancelFlowTest
|
||||||
|
|
||||||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||||
// entering pending delete phase. So it's already handled in that test case.
|
// entering pending delete phase. So it's already handled in that test case.
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_extra() throws Exception {
|
|
||||||
setupDomainWithPendingTransfer("extra");
|
|
||||||
clock.advanceOneMilli();
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "transfer cancelled");
|
|
||||||
doFailingTest("domain_transfer_cancel_extra.xml");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ import google.registry.model.contact.ContactAuthInfo;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||||
import google.registry.model.eppcommon.Trid;
|
import google.registry.model.eppcommon.Trid;
|
||||||
import google.registry.model.poll.PendingActionNotificationResponse;
|
import google.registry.model.poll.PendingActionNotificationResponse;
|
||||||
|
@ -261,13 +259,4 @@ public class DomainTransferRejectFlowTest
|
||||||
|
|
||||||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||||
// entering pending delete phase. So it's already handled in that test case.
|
// entering pending delete phase. So it's already handled in that test case.
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_extra() throws Exception {
|
|
||||||
setupDomainWithPendingTransfer("extra");
|
|
||||||
clock.advanceOneMilli();
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
|
||||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "transfer rejected");
|
|
||||||
doFailingTest("domain_transfer_reject_extra.xml");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,6 @@ import google.registry.model.contact.ContactAuthInfo;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -99,7 +97,6 @@ public class DomainTransferRequestFlowTest
|
||||||
setClientIdForFlow("NewRegistrar");
|
setClientIdForFlow("NewRegistrar");
|
||||||
setupDomain("tld");
|
setupDomain("tld");
|
||||||
createTld("flags");
|
createTld("flags");
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTransferRequested(DomainResource domain) throws Exception {
|
private void assertTransferRequested(DomainResource domain) throws Exception {
|
||||||
|
@ -778,14 +775,4 @@ public class DomainTransferRequestFlowTest
|
||||||
thrown.expect(ResourceStatusProhibitsOperationException.class);
|
thrown.expect(ResourceStatusProhibitsOperationException.class);
|
||||||
doFailingTest("domain_transfer_request.xml");
|
doFailingTest("domain_transfer_request.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_flags() throws Exception {
|
|
||||||
setEppInput("domain_transfer_request_flags.xml");
|
|
||||||
setupDomain("example", "flags");
|
|
||||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
|
||||||
thrown.expect(
|
|
||||||
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
|
@ -30,7 +29,6 @@ import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
||||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
||||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||||
|
@ -76,8 +74,6 @@ import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.domain.DesignatedContact.Type;
|
import google.registry.model.domain.DesignatedContact.Type;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -108,17 +104,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initDomainTest() {
|
public void initDomainTest() {
|
||||||
createTlds("tld", "flags");
|
createTld("tld");
|
||||||
// Super-hack premium list: The domain name has to be of the form feetype-amount for the
|
|
||||||
// test extra logic manager to be happy. So we use domain name "renew-0" to designate a premium
|
|
||||||
// name with a zero-cost update. This has nothing to do with renewals -- we just need to use a
|
|
||||||
// valid fee type.
|
|
||||||
persistResource(
|
|
||||||
Registry.get("flags").asBuilder()
|
|
||||||
.setPremiumList(persistPremiumList("flags", "renew-0,USD 100"))
|
|
||||||
.build());
|
|
||||||
// For flags extension tests.
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistReferencedEntities() {
|
private void persistReferencedEntities() {
|
||||||
|
@ -1194,105 +1180,23 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test should work, because the fee extension is not required when the fee is zero.
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndRemoveFlags_free_noFee() throws Exception {
|
public void testFailure_freePremium_wrongFee() throws Exception {
|
||||||
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "update-0"));
|
setEppInput("domain_update_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(
|
|
||||||
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_free_wrongFee() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_addremove_flags_fee.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "update-0", "FEE", "1.00"));
|
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(FeesMismatchException.class);
|
thrown.expect(FeesMismatchException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_free_correctFee() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_addremove_flags_fee.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "update-0", "FEE", "0.00"));
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(
|
|
||||||
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This should also work, even though the domain is premium (previously, a bug caused it to fail).
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_freePremium_noFee() throws Exception {
|
|
||||||
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "renew-0"));
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(
|
|
||||||
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_freePremium_wrongFee() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_addremove_flags_fee.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "renew-0", "FEE", "1.00"));
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(FeesMismatchException.class);
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_freePremium_correctFee() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_addremove_flags_fee.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "renew-0", "FEE", "0.00"));
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(
|
|
||||||
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This test should throw an exception, because the fee extension is required when the fee is not
|
// This test should throw an exception, because the fee extension is required when the fee is not
|
||||||
// zero.
|
// zero.
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndRemoveFlags_paid_noFee() throws Exception {
|
public void testFailure_missingFeeOnNonFreeUpdate() throws Exception {
|
||||||
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "update-13"));
|
setEppInput("domain_update_wildcard.xml", ImmutableMap.of("DOMAIN", "non-free-update.tld"));
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(FeesRequiredForNonFreeUpdateException.class);
|
thrown.expect(FeesRequiredForNonFreeUpdateException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_paid_wrongFee() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_addremove_flags_fee.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "update-13", "FEE", "11.00"));
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(FeesMismatchException.class);
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveFlags_paid_correctFee() throws Exception {
|
|
||||||
setEppInput(
|
|
||||||
"domain_update_addremove_flags_fee.xml",
|
|
||||||
ImmutableMap.of("DOMAIN", "update-13", "FEE", "13.00"));
|
|
||||||
persistReferencedEntities();
|
|
||||||
persistDomain();
|
|
||||||
thrown.expect(
|
|
||||||
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
|
||||||
runFlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,235 +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.flows.domain;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|
||||||
import static org.joda.money.CurrencyUnit.USD;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
|
||||||
import com.google.common.collect.Range;
|
|
||||||
import com.googlecode.objectify.Key;
|
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
|
||||||
import google.registry.model.domain.DomainResource;
|
|
||||||
import google.registry.model.domain.GracePeriod;
|
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
|
||||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
|
||||||
import google.registry.model.domain.fee.Fee;
|
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.poll.PollMessage;
|
|
||||||
import google.registry.model.registry.Registry;
|
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
|
||||||
import google.registry.pricing.PricingEngineProxy;
|
|
||||||
import google.registry.testing.AppEngineRule;
|
|
||||||
import google.registry.testing.ExceptionRule;
|
|
||||||
import google.registry.testing.FakeClock;
|
|
||||||
import google.registry.testing.InjectRule;
|
|
||||||
import google.registry.testing.ShardableTestCase;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import org.joda.money.CurrencyUnit;
|
|
||||||
import org.joda.money.Money;
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
|
||||||
public class TldSpecificLogicProxyTest extends ShardableTestCase {
|
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
|
||||||
|
|
||||||
@Rule public final ExceptionRule thrown = new ExceptionRule();
|
|
||||||
|
|
||||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
|
||||||
|
|
||||||
final FakeClock clock = new FakeClock(DateTime.parse("2010-01-01T10:00:00Z"));
|
|
||||||
|
|
||||||
Money basicCreateCost;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before() throws Exception {
|
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
createTlds("tld", "eap", "test");
|
|
||||||
RegistryExtraFlowLogicProxy.setOverride("test", TestExtraLogicManager.class);
|
|
||||||
DateTime a = clock.nowUtc().minusDays(1);
|
|
||||||
DateTime b = clock.nowUtc().plusDays(1);
|
|
||||||
persistResource(
|
|
||||||
Registry.get("eap")
|
|
||||||
.asBuilder()
|
|
||||||
.setEapFeeSchedule(
|
|
||||||
ImmutableSortedMap.of(
|
|
||||||
START_OF_TIME, Money.of(USD, 0),
|
|
||||||
a, Money.of(USD, 100),
|
|
||||||
b, Money.of(USD, 50)))
|
|
||||||
.build());
|
|
||||||
basicCreateCost =
|
|
||||||
PricingEngineProxy.getDomainCreateCost("example.tld", clock.nowUtc(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_basicCreatePrice() throws Exception {
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations createPrice =
|
|
||||||
TldSpecificLogicProxy.getCreatePrice(
|
|
||||||
Registry.get("tld"), "example.tld", "clientIdentifer", clock.nowUtc(), 1, null);
|
|
||||||
assertThat(createPrice.getTotalCost()).isEqualTo(basicCreateCost);
|
|
||||||
assertThat(createPrice.getFees()).hasSize(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_eap() throws Exception {
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations createPrice =
|
|
||||||
TldSpecificLogicProxy.getCreatePrice(
|
|
||||||
Registry.get("eap"), "example.eap", "clientId", clock.nowUtc(), 1, null);
|
|
||||||
Range<DateTime> eapValidPeriod =
|
|
||||||
Range.closedOpen(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1));
|
|
||||||
assertThat(createPrice.getTotalCost()).isEqualTo(basicCreateCost.plus(Money.of(USD, 100)));
|
|
||||||
assertThat(createPrice.getCurrency()).isEqualTo(USD);
|
|
||||||
assertThat(createPrice.getFees().get(0))
|
|
||||||
.isEqualTo(Fee.create(basicCreateCost.getAmount(), FeeType.CREATE));
|
|
||||||
assertThat(createPrice.getFees().get(1))
|
|
||||||
.isEqualTo(
|
|
||||||
Fee.create(
|
|
||||||
new BigDecimal("100.00"),
|
|
||||||
FeeType.EAP,
|
|
||||||
eapValidPeriod,
|
|
||||||
clock.nowUtc().plusDays(1)));
|
|
||||||
assertThat(createPrice.getFees())
|
|
||||||
.containsExactly(
|
|
||||||
Fee.create(basicCreateCost.getAmount(), FeeType.CREATE),
|
|
||||||
Fee.create(
|
|
||||||
new BigDecimal("100.00"),
|
|
||||||
FeeType.EAP,
|
|
||||||
eapValidPeriod,
|
|
||||||
clock.nowUtc().plusDays(1)))
|
|
||||||
.inOrder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_createPrice() throws Exception {
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations price =
|
|
||||||
TldSpecificLogicProxy.getCreatePrice(
|
|
||||||
Registry.get("test"), "create-54.test", "clientId", clock.nowUtc(), 3, null);
|
|
||||||
assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD);
|
|
||||||
assertThat(price.getFees()).hasSize(1);
|
|
||||||
assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(54));
|
|
||||||
assertThat(price.getFees().get(0).getDescription()).isEqualTo("create");
|
|
||||||
assertThat(price.getCredits()).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_renewPrice() throws Exception {
|
|
||||||
persistActiveDomain("renew--13.test");
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations price =
|
|
||||||
TldSpecificLogicProxy.getRenewPrice(
|
|
||||||
Registry.get("test"), "renew--13.test", "clientId", clock.nowUtc(), 1, null);
|
|
||||||
assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD);
|
|
||||||
assertThat(price.getFees()).isEmpty();
|
|
||||||
assertThat(price.getCredits()).hasSize(1);
|
|
||||||
assertThat(price.getCredits().get(0).getCost()).isEqualTo(new BigDecimal(-13));
|
|
||||||
assertThat(price.getCredits().get(0).getDescription()).isEqualTo("renew");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_renewPrice_noDomain() throws Exception {
|
|
||||||
thrown.expect(ResourceDoesNotExistException.class);
|
|
||||||
TldSpecificLogicProxy.getRenewPrice(
|
|
||||||
Registry.get("test"), "renew--13.test", "clientId", clock.nowUtc(), 1, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void persistPendingDeleteDomain(String domainName, DateTime now) throws Exception {
|
|
||||||
DomainResource domain = newDomainResource(domainName);
|
|
||||||
HistoryEntry historyEntry =
|
|
||||||
persistResource(
|
|
||||||
new HistoryEntry.Builder()
|
|
||||||
.setType(HistoryEntry.Type.DOMAIN_DELETE)
|
|
||||||
.setParent(domain)
|
|
||||||
.build());
|
|
||||||
domain =
|
|
||||||
persistResource(
|
|
||||||
domain
|
|
||||||
.asBuilder()
|
|
||||||
.setRegistrationExpirationTime(now.plusYears(5).plusDays(45))
|
|
||||||
.setDeletionTime(now.plusDays(35))
|
|
||||||
.addGracePeriod(
|
|
||||||
GracePeriod.create(GracePeriodStatus.REDEMPTION, now.plusDays(1), "foo", null))
|
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
|
||||||
.setDeletePollMessage(
|
|
||||||
Key.create(
|
|
||||||
persistResource(
|
|
||||||
new PollMessage.OneTime.Builder()
|
|
||||||
.setClientId("TheRegistrar")
|
|
||||||
.setEventTime(now.plusDays(5))
|
|
||||||
.setParent(historyEntry)
|
|
||||||
.build())))
|
|
||||||
.build());
|
|
||||||
clock.advanceOneMilli();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_restorePrice() throws Exception {
|
|
||||||
persistPendingDeleteDomain("renew-13.test", clock.nowUtc());
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations price =
|
|
||||||
TldSpecificLogicProxy.getRestorePrice(
|
|
||||||
Registry.get("test"), "renew-13.test", "clientId", clock.nowUtc(), null);
|
|
||||||
assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD);
|
|
||||||
assertThat(price.getFees()).hasSize(2);
|
|
||||||
assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(13));
|
|
||||||
assertThat(price.getFees().get(0).getDescription()).isEqualTo("renew");
|
|
||||||
assertThat(price.getFees().get(1).getDescription()).isEqualTo("restore");
|
|
||||||
assertThat(price.getCredits()).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_restorePrice_noDomain() throws Exception {
|
|
||||||
thrown.expect(ResourceDoesNotExistException.class);
|
|
||||||
TldSpecificLogicProxy.getRestorePrice(
|
|
||||||
Registry.get("test"), "renew-13.test", "clientId", clock.nowUtc(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_transferPrice() throws Exception {
|
|
||||||
persistActiveDomain("renew-26.test");
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations price =
|
|
||||||
TldSpecificLogicProxy.getTransferPrice(
|
|
||||||
Registry.get("test"), "renew-26.test", "clientId", clock.nowUtc(), 2, null);
|
|
||||||
assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD);
|
|
||||||
assertThat(price.getFees()).hasSize(1);
|
|
||||||
assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(26));
|
|
||||||
assertThat(price.getFees().get(0).getDescription()).isEqualTo("renew");
|
|
||||||
assertThat(price.getCredits()).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extraLogic_updatePrice() throws Exception {
|
|
||||||
persistActiveDomain("update-13.test");
|
|
||||||
TldSpecificLogicProxy.EppCommandOperations price =
|
|
||||||
TldSpecificLogicProxy.getUpdatePrice(
|
|
||||||
Registry.get("test"), "update-13.test", "clientId", clock.nowUtc(), null);
|
|
||||||
assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD);
|
|
||||||
assertThat(price.getFees()).hasSize(1);
|
|
||||||
assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(13));
|
|
||||||
assertThat(price.getFees().get(0).getDescription()).isEqualTo("update");
|
|
||||||
assertThat(price.getCredits()).isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
19
javatests/google/registry/flows/domain/testdata/domain_renew_fee_wildcard.xml
vendored
Normal file
19
javatests/google/registry/flows/domain/testdata/domain_renew_fee_wildcard.xml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<renew>
|
||||||
|
<domain:renew
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>%DOMAIN%</domain:name>
|
||||||
|
<domain:curExpDate>2000-04-03</domain:curExpDate>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
<extension>
|
||||||
|
<fee:renew xmlns:fee="urn:ietf:params:xml:ns:fee-%FEE_VERSION%">
|
||||||
|
<fee:currency>USD</fee:currency>
|
||||||
|
<fee:fee>%AMOUNT%</fee:fee>
|
||||||
|
</fee:renew>
|
||||||
|
</extension>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
24
javatests/google/registry/flows/domain/testdata/domain_renew_response_fee_wildcard.xml
vendored
Normal file
24
javatests/google/registry/flows/domain/testdata/domain_renew_response_fee_wildcard.xml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<response>
|
||||||
|
<result code="1000">
|
||||||
|
<msg>Command completed successfully</msg>
|
||||||
|
</result>
|
||||||
|
<resData>
|
||||||
|
<domain:renData
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>%DOMAIN%</domain:name>
|
||||||
|
<domain:exDate>%EX_DATE%</domain:exDate>
|
||||||
|
</domain:renData>
|
||||||
|
</resData>
|
||||||
|
<extension>
|
||||||
|
<%FEE_NS%:renData xmlns:%FEE_NS%="urn:ietf:params:xml:ns:fee-%FEE_VERSION%">
|
||||||
|
<%FEE_NS%:currency>USD</%FEE_NS%:currency>
|
||||||
|
<%FEE_NS%:fee description="renew">%AMOUNT%</%FEE_NS%:fee>
|
||||||
|
</%FEE_NS%:renData>
|
||||||
|
</extension>
|
||||||
|
<trID>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
<svTRID>server-trid</svTRID>
|
||||||
|
</trID>
|
||||||
|
</response>
|
||||||
|
</epp>
|
25
javatests/google/registry/flows/domain/testdata/domain_update_fee.xml
vendored
Normal file
25
javatests/google/registry/flows/domain/testdata/domain_update_fee.xml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<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:add/>
|
||||||
|
<domain:rem/>
|
||||||
|
<domain:chg>
|
||||||
|
<domain:registrant>sh8013</domain:registrant>
|
||||||
|
<domain:authInfo>
|
||||||
|
<domain:pw>2BARfoo</domain:pw>
|
||||||
|
</domain:authInfo>
|
||||||
|
</domain:chg>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
<extension>
|
||||||
|
<fee:update xmlns:fee="urn:ietf:params:xml:ns:fee-%FEE_VERSION%">
|
||||||
|
<fee:currency>USD</fee:currency>
|
||||||
|
<fee:fee>5.00</fee:fee>
|
||||||
|
</fee:update>
|
||||||
|
</extension>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
32
javatests/google/registry/flows/domain/testdata/domain_update_wildcard.xml
vendored
Normal file
32
javatests/google/registry/flows/domain/testdata/domain_update_wildcard.xml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<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>%DOMAIN%</domain:name>
|
||||||
|
<domain:add>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostObj>ns2.example.foo</domain:hostObj>
|
||||||
|
</domain:ns>
|
||||||
|
<domain:contact type="tech">mak21</domain:contact>
|
||||||
|
<domain:status s="clientHold"
|
||||||
|
lang="en">Payment overdue.</domain:status>
|
||||||
|
</domain:add>
|
||||||
|
<domain:rem>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostObj>ns1.example.foo</domain:hostObj>
|
||||||
|
</domain:ns>
|
||||||
|
<domain:contact type="tech">sh8013</domain:contact>
|
||||||
|
<domain:status s="clientUpdateProhibited"/>
|
||||||
|
</domain:rem>
|
||||||
|
<domain:chg>
|
||||||
|
<domain:registrant>sh8013</domain:registrant>
|
||||||
|
<domain:authInfo>
|
||||||
|
<domain:pw>2BARfoo</domain:pw>
|
||||||
|
</domain:authInfo>
|
||||||
|
</domain:chg>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
|
@ -1,328 +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;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
|
|
||||||
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;
|
|
||||||
import google.registry.model.domain.fee.BaseFee;
|
|
||||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
|
||||||
import google.registry.model.domain.fee.Credit;
|
|
||||||
import google.registry.model.domain.fee.Fee;
|
|
||||||
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
|
|
||||||
import google.registry.model.domain.flags.FlagsTransferCommandExtension;
|
|
||||||
import google.registry.model.domain.flags.FlagsUpdateCommandExtension;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fake extra logic manager which synthesizes information from the domain name for testing purposes.
|
|
||||||
*/
|
|
||||||
public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dummy exception used to signal success. This is thrown by the performAdditionalXXXLogic()
|
|
||||||
* 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
|
|
||||||
* not accessible to the test code directly. We should fix this when we make the extra flow logic
|
|
||||||
* injected.
|
|
||||||
*/
|
|
||||||
public static class TestExtraLogicManagerSuccessException extends RuntimeException {
|
|
||||||
TestExtraLogicManagerSuccessException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the flags to be used in the EPP flags extension for info commands.
|
|
||||||
*
|
|
||||||
* <p>The test extra logic manager uses domain names differently for info commands than for other
|
|
||||||
* flows. In other flows, the test logic needs returns (via the success exception) the flags found
|
|
||||||
* in the incoming message. But for info commands, there aren't any incoming flags, only outgoing
|
|
||||||
* ones. So we need to specify the flags using a dummy domain name; those flags can then be
|
|
||||||
* inserted into the outgoing info response.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Set<String> getExtensionFlags(
|
|
||||||
DomainResource domain, String clientId, DateTime asOfDate) {
|
|
||||||
// Take the part before the period, split by dashes, and treat each part after the first as
|
|
||||||
// a flag.
|
|
||||||
List<String> components =
|
|
||||||
Splitter.on('-').splitToList(
|
|
||||||
Iterables.getFirst(
|
|
||||||
Splitter.on('.').split(domain.getFullyQualifiedDomainName()), ""));
|
|
||||||
return ImmutableSet.copyOf(components.subList(1, components.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the flags to be used in the EPP flags extension for application info commands.
|
|
||||||
*
|
|
||||||
* <p>This method works the same way as getExtensionFlags().
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Set<String> getApplicationExtensionFlags(
|
|
||||||
DomainApplication application, String clientId, DateTime asOfDate) {
|
|
||||||
// Take the part before the period, split by dashes, and treat each part after the first as
|
|
||||||
// a flag.
|
|
||||||
List<String> components =
|
|
||||||
Splitter.on('-').splitToList(
|
|
||||||
Iterables.getFirst(
|
|
||||||
Splitter.on('.').split(application.getFullyQualifiedDomainName()), ""));
|
|
||||||
return ImmutableSet.copyOf(components.subList(1, components.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseFee domainNameToFeeOrCredit(String domainName) {
|
|
||||||
// The second-level domain should be of the form "description-price", where description is the
|
|
||||||
// description string of the fee or credit, and price is the price (credit if negative, fee
|
|
||||||
// otherwise). To make sure this is a valid domain name, don't use any spaces, and limit prices
|
|
||||||
// to integers. Don't use a two-character description for credits, since it is illegal to have
|
|
||||||
// both the third and fourth characters of a domain name label be hyphens.
|
|
||||||
List<String> components =
|
|
||||||
Splitter.on('-').limit(2).splitToList(
|
|
||||||
Iterables.getFirst(Splitter.on('.').split(domainName), ""));
|
|
||||||
checkArgument(components.size() == 2, "Domain name must be of the form description-price.tld");
|
|
||||||
int price = Integer.parseInt(components.get(1));
|
|
||||||
if (price < 0) {
|
|
||||||
return Credit.create(
|
|
||||||
new BigDecimal(price), FeeType.valueOf(Ascii.toUpperCase(components.get(0))));
|
|
||||||
} else {
|
|
||||||
return Fee.create(
|
|
||||||
new BigDecimal(price), FeeType.valueOf(Ascii.toUpperCase(components.get(0))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an application create command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalApplicationCreateLogic(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
FlagsCreateCommandExtension flags =
|
|
||||||
eppInput.getSingleExtension(FlagsCreateCommandExtension.class);
|
|
||||||
if (flags == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an application create command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalApplicationDeleteLogic(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("application deleted");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Computes the expected application update cost, for use in fee challenges and the like. */
|
|
||||||
@Override
|
|
||||||
public BaseFee getApplicationUpdateFeeOrCredit(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
return domainNameToFeeOrCredit(application.getFullyQualifiedDomainName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an application update command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalApplicationUpdateLogic(
|
|
||||||
DomainApplication application,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
FlagsUpdateCommandExtension flags =
|
|
||||||
eppInput.getSingleExtension(FlagsUpdateCommandExtension.class);
|
|
||||||
if (flags == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new TestExtraLogicManagerSuccessException(
|
|
||||||
"add:"
|
|
||||||
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
|
||||||
+ ";remove:"
|
|
||||||
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Computes the expected create cost, for use in fee challenges and the like. */
|
|
||||||
@Override
|
|
||||||
public BaseFee getCreateFeeOrCredit(
|
|
||||||
String domainName,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
return domainNameToFeeOrCredit(domainName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an allocate command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainAllocateLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("allocated");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a create command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainCreateLogic(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
FlagsCreateCommandExtension flags =
|
|
||||||
eppInput.getSingleExtension(FlagsCreateCommandExtension.class);
|
|
||||||
if (flags == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a delete command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainDeleteLogic(
|
|
||||||
DomainResource domainResource,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("deleted");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Computes the expected renewal cost, for use in fee challenges and the like. */
|
|
||||||
@Override
|
|
||||||
public BaseFee getRenewFeeOrCredit(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a renew command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainRenewLogic(
|
|
||||||
DomainResource domainResource,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("renewed");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a restore command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainRestoreLogic(
|
|
||||||
DomainResource domainResource,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("restored");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a transfer approve command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainTransferApproveLogic(
|
|
||||||
DomainResource domain, String clientId, HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("transfer approved");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a transfer cancel command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainTransferCancelLogic(
|
|
||||||
DomainResource domain, String clientId, HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("transfer cancelled");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a transfer reject command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainTransferRejectLogic(
|
|
||||||
DomainResource domain, String clientId, HistoryEntry historyEntry) throws EppException {
|
|
||||||
throw new TestExtraLogicManagerSuccessException("transfer rejected");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for a transfer request command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainTransferRequestLogic(
|
|
||||||
DomainResource domainResource,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
int years,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
FlagsTransferCommandExtension flags =
|
|
||||||
eppInput.getSingleExtension(FlagsTransferCommandExtension.class);
|
|
||||||
if (flags == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new TestExtraLogicManagerSuccessException(
|
|
||||||
"add:"
|
|
||||||
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
|
||||||
+ ";remove:"
|
|
||||||
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Computes the expected update cost, for use in fee challenges and the like. */
|
|
||||||
@Override
|
|
||||||
public BaseFee getUpdateFeeOrCredit(
|
|
||||||
DomainResource domain,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput) throws EppException {
|
|
||||||
return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs additional tasks required for an update command. */
|
|
||||||
@Override
|
|
||||||
public void performAdditionalDomainUpdateLogic(
|
|
||||||
DomainResource domainResource,
|
|
||||||
String clientId,
|
|
||||||
DateTime asOfDate,
|
|
||||||
EppInput eppInput,
|
|
||||||
HistoryEntry historyEntry) throws EppException {
|
|
||||||
FlagsUpdateCommandExtension flags =
|
|
||||||
eppInput.getSingleExtension(FlagsUpdateCommandExtension.class);
|
|
||||||
if (flags == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new TestExtraLogicManagerSuccessException(
|
|
||||||
"add:"
|
|
||||||
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
|
||||||
+ ";remove:"
|
|
||||||
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags()));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue