Make TRID field in async host/contact deletion non-optional

This cleans up a TODO introduced in the original bug, which allowed tasks to
have optional Trids in the case it was an older enqueued task.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154477042
This commit is contained in:
larryruili 2017-04-27 15:19:29 -07:00 committed by Ben McIlwain
parent d4d02f8977
commit 62c05c112d

View file

@ -361,15 +361,9 @@ public class DeleteContactsAndHostsAction implements Runnable {
EppResource resource, EppResource resource,
boolean deleteAllowed, boolean deleteAllowed,
DateTime now) { DateTime now) {
Optional<String> clientTransactionId = deletionRequest.clientTransactionId(); String clientTransactionId = deletionRequest.clientTransactionId();
Optional<String> serverTransactionId = deletionRequest.serverTransactionId(); String serverTransactionId = deletionRequest.serverTransactionId();
// TODO(b/36402020): Make this unconditional, once older tasks enqueued without Trid data Trid trid = Trid.create(clientTransactionId, serverTransactionId);
// have been processed out of the queue.
checkState(
clientTransactionId.isPresent() == serverTransactionId.isPresent(),
"Found one part of TRID without the other!");
if (clientTransactionId.isPresent() && serverTransactionId.isPresent()) {
Trid trid = Trid.create(clientTransactionId.get(), serverTransactionId.get());
if (resource instanceof HostResource) { if (resource instanceof HostResource) {
return ImmutableList.of( return ImmutableList.of(
HostPendingActionNotificationResponse.create( HostPendingActionNotificationResponse.create(
@ -382,8 +376,6 @@ public class DeleteContactsAndHostsAction implements Runnable {
throw new IllegalStateException("EPP resource of unknown type " + Key.create(resource)); throw new IllegalStateException("EPP resource of unknown type " + Key.create(resource));
} }
} }
return ImmutableList.of();
}
/** /**
* Determine the proper history entry type for the delete operation, as a function of * Determine the proper history entry type for the delete operation, as a function of
@ -442,10 +434,10 @@ public class DeleteContactsAndHostsAction implements Runnable {
abstract String requestingClientId(); abstract String requestingClientId();
/** First half of TRID for the original request, split for serializability. */ /** First half of TRID for the original request, split for serializability. */
abstract Optional<String> clientTransactionId(); abstract String clientTransactionId();
/** Second half of TRID for the original request, split for serializability. */ /** Second half of TRID for the original request, split for serializability. */
abstract Optional<String> serverTransactionId(); abstract String serverTransactionId();
abstract boolean isSuperuser(); abstract boolean isSuperuser();
abstract TaskHandle task(); abstract TaskHandle task();
@ -455,8 +447,8 @@ public class DeleteContactsAndHostsAction implements Runnable {
abstract Builder setKey(Key<? extends EppResource> key); abstract Builder setKey(Key<? extends EppResource> key);
abstract Builder setLastUpdateTime(DateTime lastUpdateTime); abstract Builder setLastUpdateTime(DateTime lastUpdateTime);
abstract Builder setRequestingClientId(String requestingClientId); abstract Builder setRequestingClientId(String requestingClientId);
abstract Builder setClientTransactionId(Optional<String> clientTransactionId); abstract Builder setClientTransactionId(String clientTransactionId);
abstract Builder setServerTransactionId(Optional<String> serverTransactionId); abstract Builder setServerTransactionId(String serverTransactionId);
abstract Builder setIsSuperuser(boolean isSuperuser); abstract Builder setIsSuperuser(boolean isSuperuser);
abstract Builder setTask(TaskHandle task); abstract Builder setTask(TaskHandle task);
abstract DeletionRequest build(); abstract DeletionRequest build();
@ -485,11 +477,13 @@ public class DeleteContactsAndHostsAction implements Runnable {
checkNotNull( checkNotNull(
params.get(PARAM_REQUESTING_CLIENT_ID), "Requesting client id not specified")) params.get(PARAM_REQUESTING_CLIENT_ID), "Requesting client id not specified"))
.setClientTransactionId( .setClientTransactionId(
Optional.fromNullable( checkNotNull(
params.get(PARAM_CLIENT_TRANSACTION_ID))) params.get(PARAM_CLIENT_TRANSACTION_ID),
"Client transaction id not specified"))
.setServerTransactionId( .setServerTransactionId(
Optional.fromNullable( checkNotNull(
params.get(PARAM_SERVER_TRANSACTION_ID))) params.get(PARAM_SERVER_TRANSACTION_ID),
"Server transaction id not specified"))
.setIsSuperuser( .setIsSuperuser(
Boolean.valueOf( Boolean.valueOf(
checkNotNull(params.get(PARAM_IS_SUPERUSER), "Is superuser not specified"))) checkNotNull(params.get(PARAM_IS_SUPERUSER), "Is superuser not specified")))