mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Add a custom logic framework to provide pluggable extensibility
To add additional logic for flow code, write custom classes that extend the existing custom logic classes (of which DomainCreateFlowCustomLogic is the first provided example), along with a class that extends CustomLogicFactory to provide instances of the new custom logic classes. Then configure the fully qualified class name of your new custom logic factory in ConfigModule.provideCustomLogicFactoryClass(). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=139221577
This commit is contained in:
parent
3942f0768b
commit
4d2e0941f3
15 changed files with 435 additions and 17 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static google.registry.flows.FlowUtils.persistEntityChanges;
|
||||
import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
|
||||
|
@ -57,6 +58,8 @@ import google.registry.flows.FlowModule.ClientId;
|
|||
import google.registry.flows.FlowModule.Superuser;
|
||||
import google.registry.flows.FlowModule.TargetId;
|
||||
import google.registry.flows.TransactionalFlow;
|
||||
import google.registry.flows.custom.DomainCreateFlowCustomLogic;
|
||||
import google.registry.flows.custom.EntityChanges;
|
||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -162,6 +165,7 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
@Inject @Superuser boolean isSuperuser;
|
||||
@Inject HistoryEntry.Builder historyBuilder;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject DomainCreateFlowCustomLogic customLogic;
|
||||
@Inject DomainCreateFlow() {}
|
||||
|
||||
@Override
|
||||
|
@ -198,6 +202,12 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
if (hasSignedMarks) {
|
||||
verifySignedMarksAllowed(tldState, isAnchorTenant);
|
||||
}
|
||||
customLogic.afterValidation(
|
||||
DomainCreateFlowCustomLogic.AfterValidationParameters.newBuilder()
|
||||
.setDomainName(domainName)
|
||||
.setYears(years)
|
||||
.build());
|
||||
|
||||
FeeCreateCommandExtension feeCreate =
|
||||
eppInput.getSingleExtension(FeeCreateCommandExtension.class);
|
||||
EppCommandOperations commandOperations = TldSpecificLogicProxy.getCreatePrice(
|
||||
|
@ -269,7 +279,6 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
.setContacts(command.getContacts())
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(GracePeriodStatus.ADD, createBillingEvent))
|
||||
.build();
|
||||
handleExtraFlowLogic(registry.getTldStr(), years, historyEntry, newDomain);
|
||||
entitiesToSave.add(
|
||||
newDomain,
|
||||
ForeignKeyIndex.create(newDomain, newDomain.getDeletionTime()),
|
||||
|
@ -282,7 +291,29 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
prepareMarkedLrpTokenEntity(authInfo.getPw().getValue(), domainName, historyEntry));
|
||||
}
|
||||
enqueueTasks(hasSignedMarks, hasClaimsNotice, newDomain);
|
||||
ofy().save().entities(entitiesToSave.build());
|
||||
|
||||
// TODO: Remove this section and only use the customLogic.
|
||||
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
||||
RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr());
|
||||
if (extraFlowLogic.isPresent()) {
|
||||
extraFlowLogic.get().performAdditionalDomainCreateLogic(
|
||||
newDomain,
|
||||
clientId,
|
||||
years,
|
||||
eppInput,
|
||||
historyEntry);
|
||||
}
|
||||
|
||||
EntityChanges entityChanges =
|
||||
customLogic.beforeSave(
|
||||
DomainCreateFlowCustomLogic.BeforeSaveParameters.newBuilder()
|
||||
.setNewDomain(newDomain)
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setYears(years)
|
||||
.build(),
|
||||
EntityChanges.newBuilder().setSaves(entitiesToSave.build()).build());
|
||||
persistEntityChanges(entityChanges);
|
||||
|
||||
return responseBuilder
|
||||
.setResData(DomainCreateData.create(targetId, now, registrationExpirationTime))
|
||||
.setExtensions(createResponseExtensions(feeCreate, commandOperations))
|
||||
|
@ -395,21 +426,6 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
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(
|
||||
newDomain,
|
||||
clientId,
|
||||
years,
|
||||
eppInput,
|
||||
historyEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private void enqueueTasks(
|
||||
boolean hasSignedMarks, boolean hasClaimsNotice, DomainResource newDomain) {
|
||||
if (newDomain.shouldPublishToDns()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue