diff --git a/java/google/registry/model/domain/LrpToken.java b/java/google/registry/model/domain/LrpToken.java index 0974aee6a..21a5a7472 100644 --- a/java/google/registry/model/domain/LrpToken.java +++ b/java/google/registry/model/domain/LrpToken.java @@ -18,13 +18,15 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.googlecode.objectify.Key; +import com.googlecode.objectify.annotation.EmbedMap; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Index; import google.registry.model.BackupGroupRoot; import google.registry.model.Buildable; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.reporting.HistoryEntry.Type; + +import java.util.Map; import java.util.Set; /** @@ -52,11 +54,18 @@ public class LrpToken extends BackupGroupRoot implements Buildable { Set validTlds; /** - * The key of the history entry for which the token was used. Given LRP is a domain application - * phase, this should always be a {@link Type#DOMAIN_APPLICATION_CREATE}. + * The key of the history entry for which the token was used. */ Key redemptionHistoryEntry; - + + /** + * A set of key-value properties associated with the LRP token. This map can be used to store + * additional metadata about the assignee or space of domain names for which this token can be + * valid. + */ + @EmbedMap + Map metadata; + public String getToken() { return token; } @@ -77,6 +86,10 @@ public class LrpToken extends BackupGroupRoot implements Buildable { return nullToEmptyImmutableCopy(validTlds); } + public Map getMetadata() { + return nullToEmptyImmutableCopy(metadata); + } + @Override public Builder asBuilder() { return new Builder(clone(this)); @@ -109,5 +122,10 @@ public class LrpToken extends BackupGroupRoot implements Buildable { getInstance().validTlds = validTlds; return this; } + + public Builder setMetadata(Map metadata) { + getInstance().metadata = metadata; + return this; + } } } diff --git a/javatests/google/registry/model/domain/LrpTokenTest.java b/javatests/google/registry/model/domain/LrpTokenTest.java index bf5f261de..153c76825 100644 --- a/javatests/google/registry/model/domain/LrpTokenTest.java +++ b/javatests/google/registry/model/domain/LrpTokenTest.java @@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication; import static google.registry.testing.DatastoreHelper.persistResource; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; @@ -51,6 +52,7 @@ public class LrpTokenTest extends EntityTestCase { .setAssignee("1:1020304") .setToken("a0b1c2d3e4f5g6") .setValidTlds(ImmutableSet.of("tld")) + .setMetadata(ImmutableMap.of("foo", "bar")) .build()); redeemedToken = persistResource( new LrpToken.Builder() @@ -59,6 +61,7 @@ public class LrpTokenTest extends EntityTestCase { .setRedemptionHistoryEntry( Key.create(applicationCreateHistoryEntry)) .setValidTlds(ImmutableSet.of("tld")) + .setMetadata(ImmutableMap.of("bar", "foo")) .build()); }