mirror of
https://github.com/google/nomulus.git
synced 2025-06-26 22:34:55 +02:00
Add extensible custom logic to the domain check flow
This also fixes up a hook on the domain create flow custom logic to use a single parameter, which is the general pattern we want to use going forward. It also establishes a pattern for custom logic being able to add extensions. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=139362230
This commit is contained in:
parent
fdc8ceb6bb
commit
a343648b34
7 changed files with 215 additions and 15 deletions
|
@ -41,6 +41,9 @@ import google.registry.flows.ExtensionManager;
|
|||
import google.registry.flows.Flow;
|
||||
import google.registry.flows.FlowModule.ClientId;
|
||||
import google.registry.flows.FlowModule.Superuser;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainCommand.Check;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
|
@ -106,11 +109,13 @@ public final class DomainCheckFlow implements Flow {
|
|||
@Inject @Superuser boolean isSuperuser;
|
||||
@Inject Clock clock;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject DomainCheckFlowCustomLogic customLogic;
|
||||
@Inject DomainCheckFlow() {}
|
||||
|
||||
@Override
|
||||
public EppResponse run() throws EppException {
|
||||
extensionManager.register(FeeCheckCommandExtension.class, LaunchCheckExtension.class);
|
||||
customLogic.beforeValidation();
|
||||
extensionManager.validate();
|
||||
validateClientIsLoggedIn(clientId);
|
||||
List<String> targetIds = ((Check) resourceCommand).getTargetIds();
|
||||
|
@ -133,15 +138,27 @@ public final class DomainCheckFlow implements Flow {
|
|||
}
|
||||
}
|
||||
ImmutableMap<String, InternetDomainName> domainNames = domains.build();
|
||||
customLogic.afterValidation(
|
||||
DomainCheckFlowCustomLogic.AfterValidationParameters.newBuilder()
|
||||
.setDomainNames(domainNames)
|
||||
.setAsOfDate(now)
|
||||
.build());
|
||||
Set<String> existingIds = checkResourcesExist(DomainResource.class, targetIds, now);
|
||||
ImmutableList.Builder<DomainCheck> checks = new ImmutableList.Builder<>();
|
||||
for (String targetId : targetIds) {
|
||||
String message = getMessageForCheck(domainNames.get(targetId), existingIds, now);
|
||||
checks.add(DomainCheck.create(message == null, targetId, message));
|
||||
}
|
||||
BeforeResponseReturnData responseData =
|
||||
customLogic.beforeResponse(
|
||||
BeforeResponseParameters.newBuilder()
|
||||
.setDomainChecks(checks.build())
|
||||
.setResponseExtensions(getResponseExtensions(domainNames, now))
|
||||
.setAsOfDate(now)
|
||||
.build());
|
||||
return responseBuilder
|
||||
.setResData(DomainCheckData.create(checks.build()))
|
||||
.setExtensions(getResponseExtensions(domainNames, now))
|
||||
.setResData(DomainCheckData.create(responseData.domainChecks()))
|
||||
.setExtensions(responseData.responseExtensions())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -170,7 +187,6 @@ public final class DomainCheckFlow implements Flow {
|
|||
return reservationType.getMessageForCheck();
|
||||
}
|
||||
|
||||
|
||||
/** Handle the fee check extension. */
|
||||
private ImmutableList<? extends ResponseExtension> getResponseExtensions(
|
||||
ImmutableMap<String, InternetDomainName> domainNames, DateTime now) throws EppException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue