mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Rename LrpToken to LrpTokenEntity
This is to better distinguish between an LRP "token" (the string passed along in EPP) and the datastore entity that contains the token and all metadata. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135943480
This commit is contained in:
parent
1a9f91ed9e
commit
dd9137fbd1
14 changed files with 104 additions and 97 deletions
|
@ -34,7 +34,7 @@ import google.registry.model.billing.RegistrarCredit;
|
|||
import google.registry.model.billing.RegistrarCreditBalance;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
|
@ -53,7 +53,7 @@ public final class ExportConstants {
|
|||
|
||||
/** Set of entity classes to export into BigQuery for reporting purposes. */
|
||||
@VisibleForTesting
|
||||
@SuppressWarnings("unchecked") // varargs
|
||||
@SuppressWarnings("unchecked") // varargs
|
||||
static final ImmutableSet<Class<? extends ImmutableObject>> REPORTING_ENTITY_CLASSES =
|
||||
ImmutableSet.of(
|
||||
Cancellation.class,
|
||||
|
@ -66,7 +66,7 @@ public final class ExportConstants {
|
|||
ForeignKeyHostIndex.class,
|
||||
HistoryEntry.class,
|
||||
HostResource.class,
|
||||
LrpToken.class,
|
||||
LrpTokenEntity.class,
|
||||
Modification.class,
|
||||
OneTime.class,
|
||||
PremiumList.class,
|
||||
|
|
|
@ -57,7 +57,7 @@ import google.registry.model.domain.DomainBase;
|
|||
import google.registry.model.domain.DomainBase.Builder;
|
||||
import google.registry.model.domain.DomainCommand.Create;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
|
||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||
|
@ -94,7 +94,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
protected SignedMark signedMark;
|
||||
protected boolean isAnchorTenantViaReservation;
|
||||
protected TldState tldState;
|
||||
protected Optional<LrpToken> lrpToken;
|
||||
protected Optional<LrpTokenEntity> lrpToken;
|
||||
|
||||
protected Optional<RegistryExtraFlowLogic> extraFlowLogic;
|
||||
|
||||
|
@ -206,7 +206,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
&& !isAnchorTenantViaReservation;
|
||||
lrpToken = isLrpApplication
|
||||
? TldSpecificLogicProxy.getMatchingLrpToken(command, tld)
|
||||
: Optional.<LrpToken>absent();
|
||||
: Optional.<LrpTokenEntity>absent();
|
||||
// Superusers can create reserved domains, force creations on domains that require a claims
|
||||
// notice without specifying a claims key, and override blocks on registering premium domains.
|
||||
if (!isSuperuser) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
|||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.DomainCommand.Create;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
import google.registry.model.domain.fee.BaseFee;
|
||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
||||
import google.registry.model.domain.fee.Credit;
|
||||
|
@ -266,18 +266,18 @@ public final class TldSpecificLogicProxy {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether a {@link Create} command has a valid {@link LrpToken} for a particular TLD, and
|
||||
* return that token (wrapped in an {@link Optional}) if one exists.
|
||||
* Checks whether a {@link Create} command has a valid {@link LrpTokenEntity} for a particular
|
||||
* TLD, and return that token (wrapped in an {@link Optional}) if one exists.
|
||||
*
|
||||
* <p>This method has no knowledge of whether or not an auth code (interpreted here as an LRP
|
||||
* token) has already been checked against the reserved list for QLP (anchor tenant), as auth
|
||||
* codes are used for both types of registrations.
|
||||
*/
|
||||
public static Optional<LrpToken> getMatchingLrpToken(Create createCommand, String tld) {
|
||||
public static Optional<LrpTokenEntity> getMatchingLrpToken(Create createCommand, String tld) {
|
||||
// Note that until the actual per-TLD logic is built out, what's being done here is a basic
|
||||
// domain-name-to-assignee match.
|
||||
String lrpToken = createCommand.getAuthInfo().getPw().getValue();
|
||||
LrpToken token = ofy().load().key(Key.create(LrpToken.class, lrpToken)).now();
|
||||
LrpTokenEntity token = ofy().load().key(Key.create(LrpTokenEntity.class, lrpToken)).now();
|
||||
if (token != null) {
|
||||
if (token.getAssignee().equalsIgnoreCase(createCommand.getFullyQualifiedDomainName())
|
||||
&& token.getRedemptionHistoryEntry() == null
|
||||
|
@ -285,6 +285,6 @@ public final class TldSpecificLogicProxy {
|
|||
return Optional.of(token);
|
||||
}
|
||||
}
|
||||
return Optional.<LrpToken>absent();
|
||||
return Optional.<LrpTokenEntity>absent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import google.registry.model.contact.ContactResource;
|
|||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
import google.registry.model.export.LogsExportCursor;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
|
@ -60,7 +60,7 @@ import google.registry.model.tmch.TmchCrl;
|
|||
public final class EntityClasses {
|
||||
|
||||
/** Set of entity classes. */
|
||||
@SuppressWarnings("unchecked") // varargs
|
||||
@SuppressWarnings("unchecked") // varargs
|
||||
public static final ImmutableSet<Class<? extends ImmutableObject>> ALL_CLASSES =
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
||||
BillingEvent.Cancellation.class,
|
||||
|
@ -92,7 +92,7 @@ public final class EntityClasses {
|
|||
HostResource.class,
|
||||
Lock.class,
|
||||
LogsExportCursor.class,
|
||||
LrpToken.class,
|
||||
LrpTokenEntity.class,
|
||||
PollMessage.class,
|
||||
PollMessage.Autorenew.class,
|
||||
PollMessage.OneTime.class,
|
||||
|
|
|
@ -28,11 +28,9 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An entity representing a token distributed to eligible LRP registrants.
|
||||
*/
|
||||
/** An entity representing a token distributed to eligible LRP registrants. */
|
||||
@Entity
|
||||
public class LrpToken extends BackupGroupRoot implements Buildable {
|
||||
public class LrpTokenEntity extends BackupGroupRoot implements Buildable {
|
||||
|
||||
/**
|
||||
* The secret token assigned to a registrant for the purposes of LRP registration.
|
||||
|
@ -94,11 +92,11 @@ public class LrpToken extends BackupGroupRoot implements Buildable {
|
|||
return new Builder(clone(this));
|
||||
}
|
||||
|
||||
/** A builder for constructing {@link LrpToken} objects, since they are immutable. */
|
||||
public static class Builder extends Buildable.Builder<LrpToken> {
|
||||
/** A builder for constructing {@link LrpTokenEntity} objects, since they are immutable. */
|
||||
public static class Builder extends Buildable.Builder<LrpTokenEntity> {
|
||||
public Builder() {}
|
||||
|
||||
private Builder(LrpToken instance) {
|
||||
private Builder(LrpTokenEntity instance) {
|
||||
super(instance);
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ import com.google.common.io.Files;
|
|||
import com.google.common.io.LineReader;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Work;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
import google.registry.tools.Command.RemoteApiCommand;
|
||||
import google.registry.tools.params.PathParameter;
|
||||
import google.registry.util.StringGenerator;
|
||||
|
@ -92,11 +92,11 @@ public final class CreateLrpTokensCommand implements RemoteApiCommand {
|
|||
|
||||
String line = null;
|
||||
do {
|
||||
ImmutableSet.Builder<LrpToken> tokensToSave = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<LrpTokenEntity> tokensToSave = new ImmutableSet.Builder<>();
|
||||
for (String token : generateTokens(BATCH_SIZE)) {
|
||||
line = reader.readLine();
|
||||
if (!isNullOrEmpty(line)) {
|
||||
tokensToSave.add(new LrpToken.Builder()
|
||||
tokensToSave.add(new LrpTokenEntity.Builder()
|
||||
.setAssignee(line)
|
||||
.setToken(token)
|
||||
.setValidTlds(validTlds)
|
||||
|
@ -107,13 +107,14 @@ public final class CreateLrpTokensCommand implements RemoteApiCommand {
|
|||
} while (line != null);
|
||||
}
|
||||
|
||||
private void saveTokens(final ImmutableSet<LrpToken> tokens) {
|
||||
Collection<LrpToken> savedTokens = ofy().transact(new Work<Collection<LrpToken>>() {
|
||||
@Override
|
||||
public Collection<LrpToken> run() {
|
||||
return ofy().save().entities(tokens).now().values();
|
||||
}});
|
||||
for (LrpToken token : savedTokens) {
|
||||
private void saveTokens(final ImmutableSet<LrpTokenEntity> tokens) {
|
||||
Collection<LrpTokenEntity> savedTokens =
|
||||
ofy().transact(new Work<Collection<LrpTokenEntity>>() {
|
||||
@Override
|
||||
public Collection<LrpTokenEntity> run() {
|
||||
return ofy().save().entities(tokens).now().values();
|
||||
}});
|
||||
for (LrpTokenEntity token : savedTokens) {
|
||||
System.out.printf("%s,%s%n", token.getAssignee(), token.getToken());
|
||||
}
|
||||
}
|
||||
|
@ -128,18 +129,18 @@ public final class CreateLrpTokensCommand implements RemoteApiCommand {
|
|||
private ImmutableSet<String> generateTokens(int count) {
|
||||
final ImmutableSet<String> candidates =
|
||||
ImmutableSet.copyOf(TokenUtils.createTokens(LRP, stringGenerator, count));
|
||||
ImmutableSet<Key<LrpToken>> existingTokenKeys = FluentIterable.from(candidates)
|
||||
.transform(new Function<String, Key<LrpToken>>() {
|
||||
ImmutableSet<Key<LrpTokenEntity>> existingTokenKeys = FluentIterable.from(candidates)
|
||||
.transform(new Function<String, Key<LrpTokenEntity>>() {
|
||||
@Override
|
||||
public Key<LrpToken> apply(String input) {
|
||||
return Key.create(LrpToken.class, input);
|
||||
public Key<LrpTokenEntity> apply(String input) {
|
||||
return Key.create(LrpTokenEntity.class, input);
|
||||
}})
|
||||
.toSet();
|
||||
ImmutableSet<String> existingTokenStrings = FluentIterable
|
||||
.from(ofy().load().keys(existingTokenKeys).values())
|
||||
.transform(new Function<LrpToken, String>() {
|
||||
.transform(new Function<LrpTokenEntity, String>() {
|
||||
@Override
|
||||
public String apply(LrpToken input) {
|
||||
public String apply(LrpTokenEntity input) {
|
||||
return input.getToken();
|
||||
}})
|
||||
.toSet();
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.beust.jcommander.Parameter;
|
|||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
import google.registry.tools.Command.RemoteApiCommand;
|
||||
|
||||
/** Command to show token information for LRP participants. */
|
||||
|
@ -51,19 +51,20 @@ public final class GetLrpTokenCommand implements RemoteApiCommand {
|
|||
checkArgument(
|
||||
(tokenString == null) == (assignee != null),
|
||||
"Exactly one of either token or assignee must be specified.");
|
||||
ImmutableSet.Builder<LrpToken> tokensBuilder = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<LrpTokenEntity> tokensBuilder = new ImmutableSet.Builder<>();
|
||||
if (tokenString != null) {
|
||||
LrpToken token = ofy().load().key(Key.create(LrpToken.class, tokenString)).now();
|
||||
LrpTokenEntity token =
|
||||
ofy().load().key(Key.create(LrpTokenEntity.class, tokenString)).now();
|
||||
if (token != null) {
|
||||
tokensBuilder.add(token);
|
||||
}
|
||||
} else {
|
||||
tokensBuilder.addAll(ofy().load().type(LrpToken.class).filter("assignee", assignee));
|
||||
tokensBuilder.addAll(ofy().load().type(LrpTokenEntity.class).filter("assignee", assignee));
|
||||
}
|
||||
|
||||
ImmutableSet<LrpToken> tokens = tokensBuilder.build();
|
||||
ImmutableSet<LrpTokenEntity> tokens = tokensBuilder.build();
|
||||
if (!tokens.isEmpty()) {
|
||||
for (LrpToken token : tokens) {
|
||||
for (LrpTokenEntity token : tokens) {
|
||||
System.out.println(token);
|
||||
if (includeHistory && token.getRedemptionHistoryEntry() != null) {
|
||||
System.out.println(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue