Flatten the hosts flows

There's so little meat here that there's not much
reason to break this cl up any further

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133171754
This commit is contained in:
cgoldfeder 2016-07-10 14:10:42 -04:00 committed by Ben McIlwain
parent 00ea99960a
commit 516b5663a5
12 changed files with 336 additions and 210 deletions

View file

@ -14,16 +14,42 @@
package google.registry.flows.host;
import google.registry.flows.ResourceInfoFlow;
import google.registry.model.host.HostCommand;
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
import static google.registry.model.EppResourceUtils.cloneResourceWithLinkedStatus;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.eppoutput.Result.Code.Success;
import com.google.common.base.Optional;
import google.registry.flows.EppException;
import google.registry.flows.LoggedInFlow;
import google.registry.flows.exceptions.ResourceToQueryDoesNotExistException;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppOutput;
import google.registry.model.host.HostCommand.Info;
import google.registry.model.host.HostResource;
import javax.inject.Inject;
/**
* An EPP flow that reads a host.
*
* @error {@link google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException}
* @error {@link google.registry.flows.exceptions.ResourceToQueryDoesNotExistException}
*/
public class HostInfoFlow extends ResourceInfoFlow<HostResource, HostCommand.Info> {
public class HostInfoFlow extends LoggedInFlow {
@Inject ResourceCommand resourceCommand;
@Inject Optional<AuthInfo> authInfo;
@Inject HostInfoFlow() {}
@Override
public EppOutput run() throws EppException {
Info command = (Info) resourceCommand;
String targetId = command.getTargetId();
HostResource existingResource = loadByUniqueId(HostResource.class, targetId, now);
if (existingResource == null) {
throw new ResourceToQueryDoesNotExistException(HostResource.class, targetId);
}
verifyOptionalAuthInfoForResource(authInfo, existingResource);
return createOutput(Success, cloneResourceWithLinkedStatus(existingResource, now));
}
}