mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Standardize usage of some transfer flow verification helpers
We were using verifyHasPendingTransfer() only in the domain transfer flows; now we use it in both. I also added a helper verifyTransferInitiator() even though it's only used in two places (the transfer cancel flows), because I think it streamlines the flow and makes it more consistent with the whole section of verification checking. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=150324823
This commit is contained in:
parent
7622e71dcf
commit
d8349aa0ee
5 changed files with 21 additions and 29 deletions
|
@ -17,7 +17,9 @@ package google.registry.flows.contact;
|
|||
import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.denyPendingTransfer;
|
||||
import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyHasPendingTransfer;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyTransferInitiator;
|
||||
import static google.registry.flows.contact.ContactFlowUtils.createLosingTransferPollMessage;
|
||||
import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -29,8 +31,6 @@ import google.registry.flows.ExtensionManager;
|
|||
import google.registry.flows.FlowModule.ClientId;
|
||||
import google.registry.flows.FlowModule.TargetId;
|
||||
import google.registry.flows.TransactionalFlow;
|
||||
import google.registry.flows.exceptions.NotPendingTransferException;
|
||||
import google.registry.flows.exceptions.NotTransferInitiatorException;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.metadata.MetadataExtension;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
|
@ -38,7 +38,6 @@ import google.registry.model.eppinput.ResourceCommand;
|
|||
import google.registry.model.eppoutput.EppResponse;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -75,13 +74,8 @@ public final class ContactTransferCancelFlow implements TransactionalFlow {
|
|||
DateTime now = ofy().getTransactionTime();
|
||||
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now);
|
||||
verifyOptionalAuthInfo(authInfo, existingContact);
|
||||
TransferData transferData = existingContact.getTransferData();
|
||||
if (transferData.getTransferStatus() != TransferStatus.PENDING) {
|
||||
throw new NotPendingTransferException(targetId);
|
||||
}
|
||||
if (!clientId.equals(transferData.getGainingClientId())) {
|
||||
throw new NotTransferInitiatorException();
|
||||
}
|
||||
verifyHasPendingTransfer(existingContact);
|
||||
verifyTransferInitiator(clientId, existingContact);
|
||||
ContactResource newContact =
|
||||
denyPendingTransfer(existingContact, TransferStatus.CLIENT_CANCELLED, now);
|
||||
HistoryEntry historyEntry = historyBuilder
|
||||
|
@ -95,7 +89,7 @@ public final class ContactTransferCancelFlow implements TransactionalFlow {
|
|||
ofy().save().<Object>entities(newContact, historyEntry, losingPollMessage);
|
||||
// Delete the billing event and poll messages that were written in case the transfer would have
|
||||
// been implicitly server approved.
|
||||
ofy().delete().keys(transferData.getServerApproveEntities());
|
||||
ofy().delete().keys(existingContact.getTransferData().getServerApproveEntities());
|
||||
return responseBuilder
|
||||
.setResData(createTransferResponse(targetId, newContact.getTransferData()))
|
||||
.build();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue