mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Flatten the domain and application create flows
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=136601151
This commit is contained in:
parent
43821f650e
commit
475203532e
31 changed files with 1151 additions and 1410 deletions
|
@ -14,51 +14,99 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.failfastForCreate;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.prepareMarkedLrpTokenEntity;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateLaunchCreateNotice;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateSecDnsExtension;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyClaimsNoticeIfAndOnlyIfNeeded;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyClaimsPeriodNotEnded;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyLaunchPhaseMatchesRegistryPhase;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyNoCodeMarks;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyNotReserved;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifySignedMarks;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRoid;
|
||||
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
|
||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.CommandUseErrorException;
|
||||
import google.registry.flows.EppException.StatusProhibitsOperationException;
|
||||
import google.registry.flows.FlowModule.ClientId;
|
||||
import google.registry.flows.FlowModule.TargetId;
|
||||
import google.registry.flows.LoggedInFlow;
|
||||
import google.registry.flows.TransactionalFlow;
|
||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.OneTime;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
import google.registry.model.billing.BillingEvent.Recurring;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainResource.Builder;
|
||||
import google.registry.model.domain.DomainCommand.Create;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
|
||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||
import google.registry.model.domain.metadata.MetadataExtension;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.SecDnsCreateExtension;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
import google.registry.model.eppinput.ResourceCommand;
|
||||
import google.registry.model.eppoutput.CreateData.DomainCreateData;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.model.eppoutput.Result;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.model.ofy.ObjectifyService;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.poll.PollMessage.Autorenew;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.tmch.LordnTask;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that creates a new domain resource.
|
||||
*
|
||||
* @error {@link google.registry.flows.exceptions.OnlyToolCanPassMetadataException}
|
||||
* @error {@link google.registry.flows.exceptions.ResourceAlreadyExistsException}
|
||||
* @error {@link google.registry.flows.EppException.UnimplementedExtensionException}
|
||||
* @error {@link google.registry.flows.LoggedInFlow.UndeclaredServiceExtensionException}
|
||||
* @error {@link google.registry.flows.ResourceCreateFlow.ResourceAlreadyExistsException}
|
||||
* @error {@link google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException}
|
||||
* @error {@link google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException}
|
||||
* @error {@link BaseDomainCreateFlow.AcceptedTooLongAgoException}
|
||||
* @error {@link BaseDomainCreateFlow.ClaimsPeriodEndedException}
|
||||
* @error {@link BaseDomainCreateFlow.ExpiredClaimException}
|
||||
* @error {@link BaseDomainCreateFlow.InvalidTcnIdChecksumException}
|
||||
* @error {@link BaseDomainCreateFlow.InvalidTrademarkValidatorException}
|
||||
* @error {@link BaseDomainCreateFlow.MalformedTcnIdException}
|
||||
* @error {@link BaseDomainCreateFlow.MaxSigLifeNotSupportedException}
|
||||
* @error {@link BaseDomainCreateFlow.MissingClaimsNoticeException}
|
||||
* @error {@link BaseDomainCreateFlow.UnexpectedClaimsNoticeException}
|
||||
* @error {@link BaseDomainCreateFlow.UnsupportedMarkTypeException}
|
||||
* @error {@link DomainCreateFlow.SignedMarksNotAcceptedInCurrentPhaseException}
|
||||
* @error {@link DomainFlowUtils.AcceptedTooLongAgoException}
|
||||
* @error {@link DomainFlowUtils.BadDomainNameCharacterException}
|
||||
* @error {@link DomainFlowUtils.BadDomainNamePartsCountException}
|
||||
* @error {@link DomainFlowUtils.BadPeriodUnitException}
|
||||
* @error {@link DomainFlowUtils.ClaimsPeriodEndedException}
|
||||
* @error {@link DomainFlowUtils.CurrencyUnitMismatchException}
|
||||
* @error {@link DomainFlowUtils.CurrencyValueScaleException}
|
||||
* @error {@link DomainFlowUtils.DashesInThirdAndFourthException}
|
||||
|
@ -66,14 +114,20 @@ import javax.inject.Inject;
|
|||
* @error {@link DomainFlowUtils.DomainReservedException}
|
||||
* @error {@link DomainFlowUtils.DuplicateContactForRoleException}
|
||||
* @error {@link DomainFlowUtils.EmptyDomainNamePartException}
|
||||
* @error {@link DomainFlowUtils.ExpiredClaimException}
|
||||
* @error {@link DomainFlowUtils.FeesMismatchException}
|
||||
* @error {@link DomainFlowUtils.FeesRequiredForPremiumNameException}
|
||||
* @error {@link DomainFlowUtils.InvalidIdnDomainLabelException}
|
||||
* @error {@link DomainFlowUtils.InvalidPunycodeException}
|
||||
* @error {@link DomainFlowUtils.InvalidTcnIdChecksumException}
|
||||
* @error {@link DomainFlowUtils.InvalidTrademarkValidatorException}
|
||||
* @error {@link DomainFlowUtils.LeadingDashException}
|
||||
* @error {@link DomainFlowUtils.LinkedResourcesDoNotExistException}
|
||||
* @error {@link DomainFlowUtils.LinkedResourceInPendingDeleteProhibitsOperationException}
|
||||
* @error {@link DomainFlowUtils.MalformedTcnIdException}
|
||||
* @error {@link DomainFlowUtils.MaxSigLifeNotSupportedException}
|
||||
* @error {@link DomainFlowUtils.MissingAdminContactException}
|
||||
* @error {@link DomainFlowUtils.MissingClaimsNoticeException}
|
||||
* @error {@link DomainFlowUtils.MissingContactTypeException}
|
||||
* @error {@link DomainFlowUtils.MissingRegistrantException}
|
||||
* @error {@link DomainFlowUtils.MissingTechnicalContactException}
|
||||
|
@ -85,127 +139,287 @@ import javax.inject.Inject;
|
|||
* @error {@link DomainFlowUtils.TooManyDsRecordsException}
|
||||
* @error {@link DomainFlowUtils.TooManyNameserversException}
|
||||
* @error {@link DomainFlowUtils.TrailingDashException}
|
||||
* @error {@link DomainFlowUtils.UnexpectedClaimsNoticeException}
|
||||
* @error {@link DomainFlowUtils.UnsupportedFeeAttributeException}
|
||||
* @error {@link DomainFlowUtils.UnsupportedMarkTypeException}
|
||||
* @error {@link DomainCreateFlow.DomainHasOpenApplicationsException}
|
||||
* @error {@link DomainCreateFlow.NoGeneralRegistrationsInCurrentPhaseException}
|
||||
*/
|
||||
|
||||
public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
|
||||
public class DomainCreateFlow extends LoggedInFlow implements TransactionalFlow {
|
||||
|
||||
private static final Set<TldState> QLP_SMD_ALLOWED_STATES =
|
||||
Sets.immutableEnumSet(TldState.SUNRISE, TldState.SUNRUSH);
|
||||
|
||||
@Inject AuthInfo authInfo;
|
||||
@Inject ResourceCommand resourceCommand;
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject @TargetId String targetId;
|
||||
@Inject HistoryEntry.Builder historyBuilder;
|
||||
@Inject DomainCreateFlow() {}
|
||||
|
||||
private boolean isAnchorTenant() {
|
||||
return isAnchorTenantViaReservation || isAnchorTenantViaExtension;
|
||||
@Override
|
||||
protected final void initLoggedInFlow() throws EppException {
|
||||
registerExtensions(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
|
||||
registerExtensions(
|
||||
SecDnsCreateExtension.class,
|
||||
FlagsCreateCommandExtension.class,
|
||||
MetadataExtension.class,
|
||||
LaunchCreateExtension.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void verifyDomainCreateIsAllowed() throws EppException {
|
||||
String tld = getTld();
|
||||
validateFeeChallenge(targetId, tld, now, feeCreate, commandOperations.getTotalCost());
|
||||
public final EppOutput run() throws EppException {
|
||||
Create command = cloneAndLinkReferences((Create) resourceCommand, now);
|
||||
Period period = command.getPeriod();
|
||||
verifyUnitIsYears(period);
|
||||
int years = period.getValue();
|
||||
failfastForCreate(targetId, now);
|
||||
verifyResourceDoesNotExist(DomainResource.class, targetId, now);
|
||||
// Validate that this is actually a legal domain name on a TLD that the registrar has access to.
|
||||
InternetDomainName domainName = validateDomainName(command.getFullyQualifiedDomainName());
|
||||
String domainLabel = domainName.parts().get(0);
|
||||
Registry registry = Registry.get(domainName.parent().toString());
|
||||
validateCreateCommandContactsAndNameservers(command, registry.getTldStr());
|
||||
TldState tldState = registry.getTldState(now);
|
||||
boolean isAnchorTenant = isAnchorTenant(domainName);
|
||||
LaunchCreateExtension launchCreate = eppInput.getSingleExtension(LaunchCreateExtension.class);
|
||||
boolean hasSignedMarks = launchCreate != null && !launchCreate.getSignedMarks().isEmpty();
|
||||
boolean hasClaimsNotice = launchCreate != null && launchCreate.getNotice() != null;
|
||||
if (launchCreate != null) {
|
||||
verifyNoCodeMarks(launchCreate);
|
||||
validateLaunchCreateNotice(launchCreate.getNotice(), domainLabel, isSuperuser, now);
|
||||
}
|
||||
if (hasSignedMarks) {
|
||||
verifySignedMarksAllowed(tldState, isAnchorTenant);
|
||||
}
|
||||
FeeTransformCommandExtension feeCreate =
|
||||
eppInput.getFirstExtensionOfClasses(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
|
||||
EppCommandOperations commandOperations = TldSpecificLogicProxy.getCreatePrice(
|
||||
registry, targetId, clientId, now, years, eppInput);
|
||||
validateFeeChallenge(
|
||||
targetId, registry.getTldStr(), now, feeCreate, commandOperations.getTotalCost());
|
||||
// Superusers can create reserved domains, force creations on domains that require a claims
|
||||
// notice without specifying a claims key, ignore the registry phase, and override blocks on
|
||||
// registering premium domains.
|
||||
if (!isSuperuser) {
|
||||
// Prohibit creating a domain if there is an open application for the same name.
|
||||
for (DomainApplication application : loadActiveApplicationsByDomainName(targetId, now)) {
|
||||
if (!application.getApplicationStatus().isFinalStatus()) {
|
||||
throw new DomainHasOpenApplicationsException();
|
||||
}
|
||||
checkAllowedAccessToTld(getAllowedTlds(), registry.getTldStr());
|
||||
if (launchCreate != null) {
|
||||
verifyLaunchPhaseMatchesRegistryPhase(registry, launchCreate, now);
|
||||
}
|
||||
// Prohibit registrations for non-qlp and non-superuser outside of GA.
|
||||
if (!isAnchorTenant()
|
||||
&& Registry.get(tld).getTldState(now) != TldState.GENERAL_AVAILABILITY) {
|
||||
throw new NoGeneralRegistrationsInCurrentPhaseException();
|
||||
if (!isAnchorTenant) {
|
||||
verifyNotReserved(domainName, hasSignedMarks);
|
||||
}
|
||||
if (hasClaimsNotice) {
|
||||
verifyClaimsPeriodNotEnded(registry, now);
|
||||
}
|
||||
if (now.isBefore(registry.getClaimsPeriodEnd())) {
|
||||
verifyClaimsNoticeIfAndOnlyIfNeeded(domainName, hasSignedMarks, hasClaimsNotice);
|
||||
}
|
||||
verifyPremiumNameIsNotBlocked(targetId, now, clientId);
|
||||
verifyNoOpenApplications();
|
||||
verifyIsGaOrIsSpecialCase(tldState, isAnchorTenant);
|
||||
}
|
||||
SecDnsCreateExtension secDnsCreate =
|
||||
validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class));
|
||||
String repoId = createDomainRoid(ObjectifyService.allocateId(), registry.getTldStr());
|
||||
DateTime registrationExpirationTime = leapSafeAddYears(now, years);
|
||||
HistoryEntry historyEntry = buildHistory(repoId, period);
|
||||
// Bill for the create.
|
||||
BillingEvent.OneTime createBillingEvent =
|
||||
createOneTimeBillingEvent(registry, isAnchorTenant, years, commandOperations, historyEntry);
|
||||
// Create a new autorenew billing event and poll message starting at the expiration time.
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutorenewBillingEvent(historyEntry, registrationExpirationTime);
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
createAutorenewPollMessage(historyEntry, registrationExpirationTime);
|
||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||
entitiesToSave.add(
|
||||
historyEntry,
|
||||
createBillingEvent,
|
||||
autorenewBillingEvent,
|
||||
autorenewPollMessage);
|
||||
// Bill for EAP cost, if any.
|
||||
if (!commandOperations.getEapCost().isZero()) {
|
||||
entitiesToSave.add(createEapBillingEvent(commandOperations, createBillingEvent));
|
||||
}
|
||||
DomainResource.Builder domainBuilder = new DomainResource.Builder();
|
||||
command.applyTo(domainBuilder);
|
||||
DomainResource newDomain = domainBuilder
|
||||
.setCreationClientId(clientId)
|
||||
.setCurrentSponsorClientId(clientId)
|
||||
.setRepoId(repoId)
|
||||
.setIdnTableName(validateDomainNameWithIdnTables(domainName))
|
||||
.setRegistrationExpirationTime(registrationExpirationTime)
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.setLaunchNotice(hasClaimsNotice ? launchCreate.getNotice() : null)
|
||||
.setSmdId(hasSignedMarks
|
||||
// If a signed mark was provided, then it must match the desired domain label.
|
||||
? verifySignedMarks(launchCreate.getSignedMarks(), domainLabel, now).getId()
|
||||
: null)
|
||||
.setDsData(secDnsCreate == null ? null : secDnsCreate.getDsData())
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(GracePeriodStatus.ADD, createBillingEvent))
|
||||
.build();
|
||||
handleExtraFlowLogic(registry.getTldStr(), years, historyEntry, newDomain);
|
||||
entitiesToSave.add(
|
||||
newDomain,
|
||||
ForeignKeyIndex.create(newDomain, newDomain.getDeletionTime()),
|
||||
EppResourceIndex.create(Key.create(newDomain)));
|
||||
// Anchor tenant registrations override LRP, and landrush applications can skip it.
|
||||
if (hasLrpToken(registry, isAnchorTenant)) {
|
||||
// TODO(b/32059212): This is a bug: empty tokens should still fail. Preserving to fix in a
|
||||
// separate targeted change.
|
||||
if (!authInfo.getPw().getValue().isEmpty()) {
|
||||
entitiesToSave.add(
|
||||
prepareMarkedLrpTokenEntity(authInfo.getPw().getValue(), domainName, historyEntry));
|
||||
}
|
||||
}
|
||||
enqueueTasks(hasSignedMarks, hasClaimsNotice, newDomain);
|
||||
ofy().save().entities(entitiesToSave.build());
|
||||
return createOutput(
|
||||
Result.Code.SUCCESS,
|
||||
DomainCreateData.create(targetId, now, registrationExpirationTime),
|
||||
createResponseExtensions(feeCreate, commandOperations));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void initDomainCreateOrAllocateFlow() {
|
||||
registerExtensions(LaunchCreateExtension.class);
|
||||
private boolean isAnchorTenant(InternetDomainName domainName) {
|
||||
MetadataExtension metadataExtension = eppInput.getSingleExtension(MetadataExtension.class);
|
||||
return matchesAnchorTenantReservation(domainName, authInfo.getPw().getValue())
|
||||
|| (metadataExtension != null && metadataExtension.getIsAnchorTenant());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void validateDomainLaunchCreateExtension() throws EppException {
|
||||
// We can assume launchCreate is not null here.
|
||||
// Only QLP domains can have a signed mark on a domain create, and only in sunrise or sunrush.
|
||||
if (hasSignedMarks) {
|
||||
if (isAnchorTenant() && QLP_SMD_ALLOWED_STATES.contains(
|
||||
Registry.get(getTld()).getTldState(now))) {
|
||||
return;
|
||||
}
|
||||
/** Only QLP domains can have a signed mark on a domain create, and only in sunrise or sunrush. */
|
||||
private void verifySignedMarksAllowed(TldState tldState, boolean isAnchorTenant)
|
||||
throws SignedMarksNotAcceptedInCurrentPhaseException {
|
||||
if (!isAnchorTenant || !QLP_SMD_ALLOWED_STATES.contains(tldState)) {
|
||||
throw new SignedMarksNotAcceptedInCurrentPhaseException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void setDomainCreateOrAllocateProperties(Builder builder) throws EppException {
|
||||
Registry registry = Registry.get(getTld());
|
||||
|
||||
// Bill for the create.
|
||||
BillingEvent.OneTime createEvent =
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(targetId)
|
||||
.setClientId(getClientId())
|
||||
.setPeriodYears(command.getPeriod().getValue())
|
||||
.setCost(commandOperations.getCreateCost())
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now.plus(isAnchorTenant()
|
||||
? registry.getAnchorTenantAddGracePeriodLength()
|
||||
: registry.getAddGracePeriodLength()))
|
||||
.setFlags(isAnchorTenant()
|
||||
? ImmutableSet.of(BillingEvent.Flag.ANCHOR_TENANT)
|
||||
: ImmutableSet.<BillingEvent.Flag>of())
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
ofy().save().entity(createEvent);
|
||||
|
||||
// Bill for EAP cost, if any.
|
||||
if (!commandOperations.getEapCost().isZero()) {
|
||||
BillingEvent.OneTime eapEvent =
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.FEE_EARLY_ACCESS)
|
||||
.setTargetId(createEvent.getTargetId())
|
||||
.setClientId(createEvent.getClientId())
|
||||
.setCost(commandOperations.getEapCost())
|
||||
.setEventTime(createEvent.getEventTime())
|
||||
.setBillingTime(createEvent.getBillingTime())
|
||||
.setFlags(createEvent.getFlags())
|
||||
.setParent(createEvent.getParentKey())
|
||||
.build();
|
||||
ofy().save().entity(eapEvent);
|
||||
/** Prohibit creating a domain if there is an open application for the same name. */
|
||||
private void verifyNoOpenApplications() throws DomainHasOpenApplicationsException {
|
||||
for (DomainApplication application : loadActiveApplicationsByDomainName(targetId, now)) {
|
||||
if (!application.getApplicationStatus().isFinalStatus()) {
|
||||
throw new DomainHasOpenApplicationsException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.addGracePeriod(GracePeriod.forBillingEvent(GracePeriodStatus.ADD, createEvent));
|
||||
if (launchCreate != null && (launchCreate.getNotice() != null || hasSignedMarks)) {
|
||||
builder
|
||||
.setLaunchNotice(launchCreate.getNotice())
|
||||
.setSmdId(signedMark == null ? null : signedMark.getId());
|
||||
/** Prohibit registrations for non-qlp and non-superuser outside of GA. **/
|
||||
private void verifyIsGaOrIsSpecialCase(TldState tldState, boolean isAnchorTenant)
|
||||
throws NoGeneralRegistrationsInCurrentPhaseException {
|
||||
if (!isAnchorTenant && tldState != TldState.GENERAL_AVAILABILITY) {
|
||||
throw new NoGeneralRegistrationsInCurrentPhaseException();
|
||||
}
|
||||
// Handle extra flow logic, if any. The initialization and commit are performed higher up in the
|
||||
// flow hierarchy, in BaseDomainCreateFlow.
|
||||
}
|
||||
|
||||
private HistoryEntry buildHistory(String repoId, Period period) {
|
||||
return historyBuilder
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setPeriod(period)
|
||||
.setModificationTime(now)
|
||||
.setParent(Key.create(DomainResource.class, repoId))
|
||||
.build();
|
||||
}
|
||||
|
||||
private OneTime createOneTimeBillingEvent(
|
||||
Registry registry,
|
||||
boolean isAnchorTenant,
|
||||
int years,
|
||||
EppCommandOperations commandOperations,
|
||||
HistoryEntry historyEntry) {
|
||||
return new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(targetId)
|
||||
.setClientId(clientId)
|
||||
.setPeriodYears(years)
|
||||
.setCost(commandOperations.getCreateCost())
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now.plus(isAnchorTenant
|
||||
? registry.getAnchorTenantAddGracePeriodLength()
|
||||
: registry.getAddGracePeriodLength()))
|
||||
.setFlags(isAnchorTenant
|
||||
? ImmutableSet.of(BillingEvent.Flag.ANCHOR_TENANT)
|
||||
: ImmutableSet.<BillingEvent.Flag>of())
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Recurring createAutorenewBillingEvent(
|
||||
HistoryEntry historyEntry, DateTime registrationExpirationTime) {
|
||||
return new BillingEvent.Recurring.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(targetId)
|
||||
.setClientId(clientId)
|
||||
.setEventTime(registrationExpirationTime)
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Autorenew createAutorenewPollMessage(
|
||||
HistoryEntry historyEntry, DateTime registrationExpirationTime) {
|
||||
return new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(targetId)
|
||||
.setClientId(clientId)
|
||||
.setEventTime(registrationExpirationTime)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
}
|
||||
|
||||
private OneTime createEapBillingEvent(EppCommandOperations commandOperations,
|
||||
BillingEvent.OneTime createBillingEvent) {
|
||||
return new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.FEE_EARLY_ACCESS)
|
||||
.setTargetId(createBillingEvent.getTargetId())
|
||||
.setClientId(createBillingEvent.getClientId())
|
||||
.setCost(commandOperations.getEapCost())
|
||||
.setEventTime(createBillingEvent.getEventTime())
|
||||
.setBillingTime(createBillingEvent.getBillingTime())
|
||||
.setFlags(createBillingEvent.getFlags())
|
||||
.setParent(createBillingEvent.getParentKey())
|
||||
.build();
|
||||
}
|
||||
|
||||
private boolean hasLrpToken(Registry registry, boolean isAnchorTenant) {
|
||||
return registry.getLrpPeriod().contains(now) && !isAnchorTenant;
|
||||
}
|
||||
|
||||
private void handleExtraFlowLogic(
|
||||
String tld, int years, HistoryEntry historyEntry, DomainResource newDomain)
|
||||
throws EppException {
|
||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
||||
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
||||
if (extraFlowLogic.isPresent()) {
|
||||
extraFlowLogic.get().performAdditionalDomainCreateLogic(
|
||||
existingResource,
|
||||
getClientId(),
|
||||
newDomain,
|
||||
clientId,
|
||||
now,
|
||||
command.getPeriod().getValue(),
|
||||
years,
|
||||
eppInput,
|
||||
historyEntry);
|
||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enqueueLordnTaskIfNeeded() {
|
||||
if (launchCreate != null && (launchCreate.getNotice() != null || hasSignedMarks)) {
|
||||
LordnTask.enqueueDomainResourceTask(newResource);
|
||||
private void enqueueTasks(
|
||||
boolean hasSignedMarks, boolean hasClaimsNotice, DomainResource newDomain) {
|
||||
if (newDomain.shouldPublishToDns()) {
|
||||
DnsQueue.create().addDomainRefreshTask(newDomain.getFullyQualifiedDomainName());
|
||||
}
|
||||
if (hasClaimsNotice || hasSignedMarks) {
|
||||
LordnTask.enqueueDomainResourceTask(newDomain);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final HistoryEntry.Type getHistoryEntryType() {
|
||||
return HistoryEntry.Type.DOMAIN_CREATE;
|
||||
private ImmutableList<FeeTransformResponseExtension> createResponseExtensions(
|
||||
FeeTransformCommandExtension feeCreate, EppCommandOperations commandOperations) {
|
||||
return (feeCreate == null)
|
||||
? null
|
||||
: ImmutableList.of(createFeeCreateResponse(feeCreate, commandOperations));
|
||||
}
|
||||
|
||||
/** There is an open application for this domain. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue