mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 23:33:36 +02:00
Turn Flow into an interface and inject all its fields
This concludes your flow flattening experience. Please fill out a flow flattening satisfaction survey before exiting. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137903095
This commit is contained in:
parent
82b0bff9b5
commit
053538b1b5
49 changed files with 630 additions and 569 deletions
|
@ -17,19 +17,20 @@ package google.registry.flows.session;
|
|||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ExtensionManager;
|
||||
import google.registry.flows.Flow;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.model.eppoutput.Greeting;
|
||||
import google.registry.util.Clock;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** A flow for an Epp "hello". */
|
||||
public class HelloFlow extends Flow {
|
||||
public class HelloFlow implements Flow {
|
||||
|
||||
@Inject ExtensionManager extensionManager;
|
||||
@Inject Clock clock;
|
||||
@Inject HelloFlow() {}
|
||||
|
||||
@Override
|
||||
public EppOutput run() throws EppException {
|
||||
public Greeting run() throws EppException {
|
||||
extensionManager.validate(); // There are no legal extensions for this flow.
|
||||
return EppOutput.create(Greeting.create(now));
|
||||
return Greeting.create(clock.nowUtc());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,15 @@ import google.registry.flows.EppException.UnimplementedOptionException;
|
|||
import google.registry.flows.ExtensionManager;
|
||||
import google.registry.flows.Flow;
|
||||
import google.registry.flows.FlowModule.ClientId;
|
||||
import google.registry.flows.SessionMetadata;
|
||||
import google.registry.flows.TransportCredentials;
|
||||
import google.registry.model.eppcommon.ProtocolDefinition;
|
||||
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppinput.EppInput.Login;
|
||||
import google.registry.model.eppinput.EppInput.Options;
|
||||
import google.registry.model.eppinput.EppInput.Services;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.model.eppoutput.Result.Code;
|
||||
import google.registry.model.eppoutput.EppResponse;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import java.util.Set;
|
||||
|
@ -62,7 +64,7 @@ import javax.inject.Inject;
|
|||
* @error {@link LoginFlow.RegistrarAccountNotActiveException}
|
||||
* @error {@link LoginFlow.UnsupportedLanguageException}
|
||||
*/
|
||||
public class LoginFlow extends Flow {
|
||||
public class LoginFlow implements Flow {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
|
||||
|
@ -70,12 +72,16 @@ public class LoginFlow extends Flow {
|
|||
private static final int MAX_FAILED_LOGIN_ATTEMPTS_PER_CONNECTION = 3;
|
||||
|
||||
@Inject ExtensionManager extensionManager;
|
||||
@Inject EppInput eppInput;
|
||||
@Inject SessionMetadata sessionMetadata;
|
||||
@Inject TransportCredentials credentials;
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject LoginFlow() {}
|
||||
|
||||
/** Run the flow and log errors. */
|
||||
@Override
|
||||
public final EppOutput run() throws EppException {
|
||||
public final EppResponse run() throws EppException {
|
||||
try {
|
||||
return runWithoutLogging();
|
||||
} catch (EppException e) {
|
||||
|
@ -85,7 +91,7 @@ public class LoginFlow extends Flow {
|
|||
}
|
||||
|
||||
/** Run the flow without bothering to log errors. The {@link #run} method will do that for us. */
|
||||
public final EppOutput runWithoutLogging() throws EppException {
|
||||
public final EppResponse runWithoutLogging() throws EppException {
|
||||
extensionManager.validate(); // There are no legal extensions for this flow.
|
||||
Login login = (Login) eppInput.getCommandWrapper().getCommand();
|
||||
if (!clientId.isEmpty()) {
|
||||
|
@ -137,7 +143,7 @@ public class LoginFlow extends Flow {
|
|||
sessionMetadata.resetFailedLoginAttempts();
|
||||
sessionMetadata.setClientId(login.getClientId());
|
||||
sessionMetadata.setServiceExtensionUris(serviceExtensionUrisBuilder.build());
|
||||
return createOutput(Code.SUCCESS);
|
||||
return responseBuilder.build();
|
||||
}
|
||||
|
||||
/** Registrar with this client ID could not be found. */
|
||||
|
|
|
@ -21,7 +21,8 @@ import google.registry.flows.EppException;
|
|||
import google.registry.flows.ExtensionManager;
|
||||
import google.registry.flows.Flow;
|
||||
import google.registry.flows.FlowModule.ClientId;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.flows.SessionMetadata;
|
||||
import google.registry.model.eppoutput.EppResponse;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
|
@ -29,17 +30,19 @@ import javax.inject.Inject;
|
|||
*
|
||||
* @error {@link google.registry.flows.FlowUtils.NotLoggedInException}
|
||||
*/
|
||||
public class LogoutFlow extends Flow {
|
||||
public class LogoutFlow implements Flow {
|
||||
|
||||
@Inject ExtensionManager extensionManager;
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject SessionMetadata sessionMetadata;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject LogoutFlow() {}
|
||||
|
||||
@Override
|
||||
public final EppOutput run() throws EppException {
|
||||
public final EppResponse run() throws EppException {
|
||||
extensionManager.validate(); // There are no legal extensions for this flow.
|
||||
validateClientIsLoggedIn(clientId);
|
||||
sessionMetadata.invalidate();
|
||||
return createOutput(SUCCESS_AND_CLOSE);
|
||||
return responseBuilder.setResultFromCode(SUCCESS_AND_CLOSE).build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue