mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 20:18:34 +02:00
Add allowedEppActions to AllocationToken Java classes (#1958)
* Add allowedEppActions field to AllocationToken Java class and converter * Add getter and setter
This commit is contained in:
parent
3d809e762b
commit
815be8000a
5 changed files with 52 additions and 0 deletions
|
@ -45,6 +45,7 @@ import google.registry.model.CreateAutoTimestamp;
|
||||||
import google.registry.model.UpdateAutoTimestampEntity;
|
import google.registry.model.UpdateAutoTimestampEntity;
|
||||||
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||||
import google.registry.model.common.TimedTransitionProperty;
|
import google.registry.model.common.TimedTransitionProperty;
|
||||||
|
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||||
import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.persistence.WithVKey;
|
import google.registry.persistence.WithVKey;
|
||||||
|
@ -213,6 +214,9 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||||
TimedTransitionProperty<TokenStatus> tokenStatusTransitions =
|
TimedTransitionProperty<TokenStatus> tokenStatusTransitions =
|
||||||
TimedTransitionProperty.withInitialValue(NOT_STARTED);
|
TimedTransitionProperty.withInitialValue(NOT_STARTED);
|
||||||
|
|
||||||
|
/** Allowed EPP actions for this token, or null if all actions are allowed. */
|
||||||
|
@Nullable Set<CommandName> allowedEppActions;
|
||||||
|
|
||||||
public String getToken() {
|
public String getToken() {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
@ -263,6 +267,10 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||||
return tokenStatusTransitions;
|
return tokenStatusTransitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImmutableSet<CommandName> getAllowedEppActions() {
|
||||||
|
return nullToEmptyImmutableCopy(allowedEppActions);
|
||||||
|
}
|
||||||
|
|
||||||
public RenewalPriceBehavior getRenewalPriceBehavior() {
|
public RenewalPriceBehavior getRenewalPriceBehavior() {
|
||||||
return renewalPriceBehavior;
|
return renewalPriceBehavior;
|
||||||
}
|
}
|
||||||
|
@ -450,6 +458,11 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setAllowedEppActions(Set<CommandName> allowedEppActions) {
|
||||||
|
getInstance().allowedEppActions = forceEmptyToNull(allowedEppActions);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setRenewalPriceBehavior(RenewalPriceBehavior renewalPriceBehavior) {
|
public Builder setRenewalPriceBehavior(RenewalPriceBehavior renewalPriceBehavior) {
|
||||||
getInstance().renewalPriceBehavior = renewalPriceBehavior;
|
getInstance().renewalPriceBehavior = renewalPriceBehavior;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright 2023 The Nomulus Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package google.registry.persistence.converter;
|
||||||
|
|
||||||
|
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem;
|
||||||
|
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||||
|
import javax.persistence.Converter;
|
||||||
|
|
||||||
|
@Converter(autoApply = true)
|
||||||
|
public class CommandNameSetConverter
|
||||||
|
extends StringSetConverterBase<FeeQueryCommandExtensionItem.CommandName> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String toString(CommandName element) {
|
||||||
|
return element.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
CommandName fromString(String value) {
|
||||||
|
return FeeQueryCommandExtensionItem.CommandName.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,6 +85,7 @@
|
||||||
<class>google.registry.persistence.converter.BillingEventFlagSetConverter</class>
|
<class>google.registry.persistence.converter.BillingEventFlagSetConverter</class>
|
||||||
<class>google.registry.persistence.converter.BloomFilterConverter</class>
|
<class>google.registry.persistence.converter.BloomFilterConverter</class>
|
||||||
<class>google.registry.persistence.converter.CidrAddressBlockListConverter</class>
|
<class>google.registry.persistence.converter.CidrAddressBlockListConverter</class>
|
||||||
|
<class>google.registry.persistence.converter.CommandNameSetConverter</class>
|
||||||
<class>google.registry.persistence.converter.CurrencyToBillingConverter</class>
|
<class>google.registry.persistence.converter.CurrencyToBillingConverter</class>
|
||||||
<class>google.registry.persistence.converter.CurrencyUnitConverter</class>
|
<class>google.registry.persistence.converter.CurrencyUnitConverter</class>
|
||||||
<class>google.registry.persistence.converter.DatabaseMigrationScheduleTransitionConverter</class>
|
<class>google.registry.persistence.converter.DatabaseMigrationScheduleTransitionConverter</class>
|
||||||
|
|
|
@ -37,6 +37,7 @@ import google.registry.model.Buildable;
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
|
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||||
import google.registry.model.domain.token.AllocationToken.RegistrationBehavior;
|
import google.registry.model.domain.token.AllocationToken.RegistrationBehavior;
|
||||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||||
import google.registry.model.domain.token.AllocationToken.TokenType;
|
import google.registry.model.domain.token.AllocationToken.TokenType;
|
||||||
|
@ -77,6 +78,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||||
.put(DateTime.now(UTC), TokenStatus.VALID)
|
.put(DateTime.now(UTC), TokenStatus.VALID)
|
||||||
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
||||||
.build())
|
.build())
|
||||||
|
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||||
.build());
|
.build());
|
||||||
assertThat(loadByEntity(unlimitedUseToken)).isEqualTo(unlimitedUseToken);
|
assertThat(loadByEntity(unlimitedUseToken)).isEqualTo(unlimitedUseToken);
|
||||||
|
|
||||||
|
@ -113,6 +115,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||||
.put(DateTime.now(UTC), TokenStatus.VALID)
|
.put(DateTime.now(UTC), TokenStatus.VALID)
|
||||||
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
||||||
.build())
|
.build())
|
||||||
|
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||||
.build());
|
.build());
|
||||||
AllocationToken persisted = loadByEntity(unlimitedUseToken);
|
AllocationToken persisted = loadByEntity(unlimitedUseToken);
|
||||||
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
|
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
token text not null,
|
token text not null,
|
||||||
update_timestamp timestamptz,
|
update_timestamp timestamptz,
|
||||||
allowed_registrar_ids text[],
|
allowed_registrar_ids text[],
|
||||||
|
allowed_epp_actions text[],
|
||||||
allowed_tlds text[],
|
allowed_tlds text[],
|
||||||
creation_time timestamptz not null,
|
creation_time timestamptz not null,
|
||||||
discount_fraction float8 not null,
|
discount_fraction float8 not null,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue