mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Dual-read RegistryCursor prior to Cursor cutover
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125057857
This commit is contained in:
parent
5a4877805b
commit
3e0963dfdb
2 changed files with 55 additions and 2 deletions
|
@ -73,8 +73,21 @@ public class RegistryCursor extends ImmutableObject {
|
|||
|
||||
DateTime date;
|
||||
|
||||
/** Convenience shortcut to load a cursor for a given registry and cursor type. */
|
||||
/**
|
||||
* Convenience shortcut to load a cursor (as an {@link Optional}) for a given registry and cursor
|
||||
* type. Note that this currently reads the new cursor style first, then fails back to the old
|
||||
* RegistryCursor if the corresponding new style cursor does not exist.
|
||||
*/
|
||||
public static Optional<DateTime> load(Registry registry, CursorType cursorType) {
|
||||
Cursor newStyleCursor =
|
||||
ofy()
|
||||
.load()
|
||||
.key(Cursor.createKey(Cursor.CursorType.valueOf(cursorType.name()), registry))
|
||||
.now();
|
||||
if (newStyleCursor != null) {
|
||||
return Optional.of(newStyleCursor.getCursorTime());
|
||||
}
|
||||
// New cursor style wasn't found for this TLD and cursor type, so load the old style.
|
||||
Key<RegistryCursor> key =
|
||||
Key.create(Key.create(registry), RegistryCursor.class, cursorType.name());
|
||||
RegistryCursor cursor = ofy().load().key(key).now();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue