mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Swap id and indexed field in LrpToken
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130014294
This commit is contained in:
parent
159528fb6f
commit
2e88129c43
3 changed files with 30 additions and 26 deletions
|
@ -25,7 +25,6 @@ import google.registry.model.BackupGroupRoot;
|
||||||
import google.registry.model.Buildable;
|
import google.registry.model.Buildable;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.model.reporting.HistoryEntry.Type;
|
import google.registry.model.reporting.HistoryEntry.Type;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,18 +33,19 @@ import java.util.Set;
|
||||||
@Entity
|
@Entity
|
||||||
public class LrpToken extends BackupGroupRoot implements Buildable {
|
public class LrpToken extends BackupGroupRoot implements Buildable {
|
||||||
|
|
||||||
/**
|
|
||||||
* The token's assignee (a unique identifier).
|
|
||||||
*/
|
|
||||||
@Id
|
|
||||||
String assignee;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The secret token assigned to a registrant for the purposes of LRP registration.
|
* The secret token assigned to a registrant for the purposes of LRP registration.
|
||||||
*/
|
*/
|
||||||
@Index
|
@Id
|
||||||
String token;
|
String token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The token's assignee (additional metadata for identifying the owner of the token, which may
|
||||||
|
* vary from TLD to TLD).
|
||||||
|
*/
|
||||||
|
@Index
|
||||||
|
String assignee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of TLDs for which this LRP token is valid.
|
* A list of TLDs for which this LRP token is valid.
|
||||||
*/
|
*/
|
||||||
|
@ -89,7 +89,7 @@ public class LrpToken extends BackupGroupRoot implements Buildable {
|
||||||
private Builder(LrpToken instance) {
|
private Builder(LrpToken instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setAssignee(String assignee) {
|
public Builder setAssignee(String assignee) {
|
||||||
getInstance().assignee = assignee;
|
getInstance().assignee = assignee;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpToken;
|
||||||
import google.registry.tools.Command.GtechCommand;
|
import google.registry.tools.Command.GtechCommand;
|
||||||
|
@ -51,22 +52,25 @@ public final class GetLrpTokenCommand implements RemoteApiCommand, GtechCommand
|
||||||
checkArgument(
|
checkArgument(
|
||||||
(tokenString == null) == (assignee != null),
|
(tokenString == null) == (assignee != null),
|
||||||
"Exactly one of either token or assignee must be specified.");
|
"Exactly one of either token or assignee must be specified.");
|
||||||
LrpToken token = null;
|
ImmutableSet.Builder<LrpToken> tokensBuilder = ImmutableSet.builder();
|
||||||
if (assignee != null) {
|
if (tokenString != null) {
|
||||||
token = ofy().load().key(Key.create(LrpToken.class, assignee)).now();
|
LrpToken token = ofy().load().key(Key.create(LrpToken.class, tokenString)).now();
|
||||||
} else if (tokenString != null) {
|
if (token != null) {
|
||||||
token = ofy().load()
|
tokensBuilder.add(token);
|
||||||
.type(LrpToken.class)
|
|
||||||
.filter("token", tokenString)
|
|
||||||
.first()
|
|
||||||
.now();
|
|
||||||
}
|
|
||||||
if (token != null) {
|
|
||||||
System.out.println(token);
|
|
||||||
if (includeHistory && token.getRedemptionHistoryEntry() != null) {
|
|
||||||
System.out.println(
|
|
||||||
ofy().load().key(token.getRedemptionHistoryEntry()).now().toHydratedString());
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tokensBuilder.addAll(ofy().load().type(LrpToken.class).filter("assignee", assignee));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImmutableSet<LrpToken> tokens = tokensBuilder.build();
|
||||||
|
if (!tokens.isEmpty()) {
|
||||||
|
for (LrpToken token : tokens) {
|
||||||
|
System.out.println(token);
|
||||||
|
if (includeHistory && token.getRedemptionHistoryEntry() != null) {
|
||||||
|
System.out.println(
|
||||||
|
ofy().load().key(token.getRedemptionHistoryEntry()).now().toHydratedString());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Token not found.");
|
System.out.println("Token not found.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,10 +285,10 @@ class google.registry.model.domain.GracePeriod {
|
||||||
org.joda.time.DateTime expirationTime;
|
org.joda.time.DateTime expirationTime;
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.LrpToken {
|
class google.registry.model.domain.LrpToken {
|
||||||
@Id java.lang.String assignee;
|
@Id java.lang.String token;
|
||||||
com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
|
com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
java.lang.String token;
|
java.lang.String assignee;
|
||||||
java.util.Set<java.lang.String> validTlds;
|
java.util.Set<java.lang.String> validTlds;
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.Period {
|
class google.registry.model.domain.Period {
|
||||||
|
|
Loading…
Add table
Reference in a new issue