Flatten the domain check flows

Also pull out a small bit of common functionality across contact and host checks.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133977324
This commit is contained in:
cgoldfeder 2016-09-22 11:24:57 -07:00 committed by Ben McIlwain
parent b5e421cee3
commit 025a4ae012
7 changed files with 161 additions and 101 deletions

View file

@ -14,6 +14,7 @@
package google.registry.flows.host;
import static google.registry.flows.ResourceFlowUtils.verifyTargetIdCount;
import static google.registry.model.EppResourceUtils.checkResourcesExist;
import static google.registry.model.eppoutput.Result.Code.SUCCESS;
@ -21,7 +22,6 @@ import com.google.common.collect.ImmutableList;
import google.registry.config.ConfigModule.Config;
import google.registry.flows.EppException;
import google.registry.flows.LoggedInFlow;
import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CheckData.HostCheck;
import google.registry.model.eppoutput.CheckData.HostCheckData;
@ -48,9 +48,7 @@ public final class HostCheckFlow extends LoggedInFlow {
@Override
protected final EppOutput run() throws EppException {
List<String> targetIds = ((Check) resourceCommand).getTargetIds();
if (targetIds.size() > maxChecks) {
throw new TooManyResourceChecksException(maxChecks);
}
verifyTargetIdCount(targetIds, maxChecks);
Set<String> existingIds = checkResourcesExist(HostResource.class, targetIds, now);
ImmutableList.Builder<HostCheck> checks = new ImmutableList.Builder<>();
for (String id : targetIds) {