Do not cancel pending transfers unless there is one to cancel

A previous CL inadvertently caused the system to always set the transfer status to SERVER_CANCELLED when deleting a resource, even if there was no transfer. This led to RDE problems.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140890919
This commit is contained in:
mountford 2016-12-02 14:03:30 -08:00 committed by Ben McIlwain
parent 7cf29366bc
commit c0d9b54872
5 changed files with 37 additions and 7 deletions

View file

@ -63,6 +63,7 @@ import google.registry.model.ImmutableObject;
import google.registry.model.annotations.ExternalMessagingName;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
@ -317,10 +318,12 @@ public class DeleteContactsAndHostsAction implements Runnable {
EppResource.Builder<?, ?> resourceToSaveBuilder;
if (resource instanceof ContactResource) {
ContactResource contact = (ContactResource) resource;
resourceToSaveBuilder = contact.asBuilder()
.setTransferData(createResolvedTransferData(
contact.getTransferData(), TransferStatus.SERVER_CANCELLED, now))
.wipeOut();
ContactResource.Builder contactToSaveBuilder = contact.asBuilder();
if (contact.getStatusValues().contains(StatusValue.PENDING_TRANSFER)) {
contactToSaveBuilder = contactToSaveBuilder.setTransferData(createResolvedTransferData(
contact.getTransferData(), TransferStatus.SERVER_CANCELLED, now));
}
resourceToSaveBuilder = contactToSaveBuilder.wipeOut();
} else {
resourceToSaveBuilder = resource.asBuilder();
}