mirror of
https://github.com/google/nomulus
synced 2026-05-28 10:40:44 +00:00
Append event year to poll message external IDs
This solves the problem of external poll message IDs not being globally unique by simply appending the event year. This means that autorenew poll messages will increment by one every year, so they will always be unique. This also requires no data schema changes, and thus most importantly, no data migration. Incoming requests lacking this new year field will continue to work for now for backwards compatibility reasons. This is possible because we don't actually use the year for anything. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178012685
This commit is contained in:
@@ -19,6 +19,7 @@ import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.poll.PollFlowUtils.getPollMessagesQuery;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_NO_MESSAGES;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.poll.PollMessageExternalKeyConverter.parsePollMessageExternalId;
|
||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
@@ -71,7 +72,7 @@ public class PollAckFlow implements TransactionalFlow {
|
||||
Key<PollMessage> pollMessageKey;
|
||||
// Try parsing the messageId, and throw an exception if it's invalid.
|
||||
try {
|
||||
pollMessageKey = PollMessage.EXTERNAL_KEY_CONVERTER.reverse().convert(messageId);
|
||||
pollMessageKey = parsePollMessageExternalId(messageId);
|
||||
} catch (PollMessageExternalKeyParseException e) {
|
||||
throw new InvalidMessageIdException(messageId);
|
||||
}
|
||||
@@ -84,6 +85,9 @@ public class PollAckFlow implements TransactionalFlow {
|
||||
if (pollMessage == null || !isBeforeOrAt(pollMessage.getEventTime(), now)) {
|
||||
throw new MessageDoesNotExistException(messageId);
|
||||
}
|
||||
// TODO(b/68953444): Once the year field on the external poll message ID becomes mandatory, add
|
||||
// a check that the value of the year field is correct, by checking that
|
||||
// makePollMessageExternalId(pollMessage) equals messageId.
|
||||
|
||||
// Make sure this client is authorized to ack this message. It could be that the message is
|
||||
// supposed to go to a different registrar.
|
||||
|
||||
@@ -18,8 +18,8 @@ import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.poll.PollFlowUtils.getPollMessagesQuery;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACK_MESSAGE;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_NO_MESSAGES;
|
||||
import static google.registry.model.poll.PollMessageExternalKeyConverter.makePollMessageExternalId;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
|
||||
import google.registry.flows.ExtensionManager;
|
||||
@@ -73,7 +73,7 @@ public class PollRequestFlow implements Flow {
|
||||
.setQueueDate(pollMessage.getEventTime())
|
||||
.setMsg(pollMessage.getMsg())
|
||||
.setQueueLength(getPollMessagesQuery(clientId, now).count())
|
||||
.setMessageId(PollMessage.EXTERNAL_KEY_CONVERTER.convert(Key.create(pollMessage)))
|
||||
.setMessageId(makePollMessageExternalId(pollMessage))
|
||||
.build())
|
||||
.setMultipleResData(pollMessage.getResponseData())
|
||||
.setExtensions(pollMessage.getResponseExtensions())
|
||||
|
||||
Reference in New Issue
Block a user