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:
mcilwain 2017-12-05 14:35:37 -08:00 committed by jianglai
parent 8e33bc898f
commit 931156fdd7
26 changed files with 270 additions and 127 deletions

View file

@ -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.