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:
cgoldfeder 2016-11-01 19:50:31 -07:00 committed by Ben McIlwain
parent 82b0bff9b5
commit 053538b1b5
49 changed files with 630 additions and 569 deletions

View file

@ -22,7 +22,6 @@ import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWit
import static google.registry.flows.domain.DomainFlowUtils.verifyClaimsPeriodNotEnded;
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPredelegation;
import static google.registry.model.domain.launch.LaunchPhase.CLAIMS;
import static google.registry.model.eppoutput.Result.Code.SUCCESS;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -33,20 +32,23 @@ import google.registry.flows.EppException.CommandUseErrorException;
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.model.domain.DomainCommand.Check;
import google.registry.model.domain.launch.LaunchCheckExtension;
import google.registry.model.domain.launch.LaunchCheckResponseExtension;
import google.registry.model.domain.launch.LaunchCheckResponseExtension.LaunchCheck;
import google.registry.model.domain.launch.LaunchCheckResponseExtension.LaunchCheckName;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppOutput;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.tmch.ClaimsListShard;
import google.registry.util.Clock;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import org.joda.time.DateTime;
/**
* An EPP flow that checks whether strings are trademarked.
@ -58,16 +60,19 @@ import javax.inject.Inject;
* @error {@link DomainFlowUtils.TldDoesNotExistException}
* @error {@link ClaimsCheckNotAllowedInSunrise}
*/
public final class ClaimsCheckFlow extends Flow {
public final class ClaimsCheckFlow implements Flow {
@Inject ExtensionManager extensionManager;
@Inject ResourceCommand resourceCommand;
@Inject @ClientId String clientId;
@Inject @Superuser boolean isSuperuser;
@Inject Clock clock;
@Inject @Config("maxChecks") int maxChecks;
@Inject EppResponse.Builder responseBuilder;
@Inject ClaimsCheckFlow() {}
@Override
public EppOutput run() throws EppException {
public EppResponse run() throws EppException {
extensionManager.register(LaunchCheckExtension.class);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
@ -84,6 +89,7 @@ public final class ClaimsCheckFlow extends Flow {
checkAllowedAccessToTld(clientId, tld);
Registry registry = Registry.get(tld);
if (!isSuperuser) {
DateTime now = clock.nowUtc();
verifyNotInPredelegation(registry, now);
if (registry.getTldState(now) == TldState.SUNRISE) {
throw new ClaimsCheckNotAllowedInSunrise();
@ -96,10 +102,9 @@ public final class ClaimsCheckFlow extends Flow {
LaunchCheck.create(
LaunchCheckName.create(claimKey != null, targetId), claimKey));
}
return createOutput(
SUCCESS,
null,
ImmutableList.of(LaunchCheckResponseExtension.create(CLAIMS, launchChecksBuilder.build())));
return responseBuilder
.setOnlyExtension(LaunchCheckResponseExtension.create(CLAIMS, launchChecksBuilder.build()))
.build();
}
/** Claims checks are not allowed during sunrise. */