mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Add domain name support to AllocationToken entities
The design doc is at [] The next step will be to tie this into the domain create flow, and if the domain name is on a reserved list, allow it to be created if the token is specified that has the given domain name on it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=207884521
This commit is contained in:
parent
e3977024f3
commit
d80f431e21
5 changed files with 117 additions and 24 deletions
|
@ -21,12 +21,14 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
|||
import com.googlecode.objectify.Key;
|
||||
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.CreateAutoTimestamp;
|
||||
import google.registry.model.annotations.ReportedOn;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** An entity representing an allocation token. */
|
||||
|
@ -40,6 +42,9 @@ public class AllocationToken extends BackupGroupRoot implements Buildable {
|
|||
/** The key of the history entry for which the token was used. Null if not yet used. */
|
||||
Key<HistoryEntry> redemptionHistoryEntry;
|
||||
|
||||
/** The fully-qualified domain name that this token is limited to, if any. */
|
||||
@Nullable @Index String domainName;
|
||||
|
||||
/** When this token was created. */
|
||||
CreateAutoTimestamp creationTime = CreateAutoTimestamp.create(null);
|
||||
|
||||
|
@ -55,6 +60,10 @@ public class AllocationToken extends BackupGroupRoot implements Buildable {
|
|||
return redemptionHistoryEntry != null;
|
||||
}
|
||||
|
||||
public Optional<String> getDomainName() {
|
||||
return Optional.ofNullable(domainName);
|
||||
}
|
||||
|
||||
public Optional<DateTime> getCreationTime() {
|
||||
return Optional.ofNullable(creationTime.getTimestamp());
|
||||
}
|
||||
|
@ -86,6 +95,11 @@ public class AllocationToken extends BackupGroupRoot implements Buildable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setDomainName(@Nullable String domainName) {
|
||||
getInstance().domainName = domainName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCreationTime(DateTime creationTime) {
|
||||
checkState(
|
||||
getInstance().creationTime.getTimestamp() == null, "creationTime can only be set once");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue