mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Move ROID suffix handling from RegistryConfig to ConfigModule
This is the first in a decently long series of commits to delete RegistryConfig entirely and centralize all configuration in ConfigModule using Dagger. Once this is done, then the text-based YAML configuration work can begin in earnest. Note that the configuration settings from TestRegistryConfig will be moving into ConfigModule.LocalTestConfig. This way they can be referred to in a static context from test and test utility helpers, rather than having to be injected everywhere, which we don't typically bother with for tests. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143473089
This commit is contained in:
parent
ab3f352782
commit
0b112f17a7
11 changed files with 43 additions and 46 deletions
|
@ -113,6 +113,19 @@ public final class ConfigModule {
|
|||
return "Nomulus";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the roid suffix to be used for the roids of all contacts and hosts. E.g. a value of
|
||||
* "ROID" would end up creating roids that look like "ABC123-ROID".
|
||||
*
|
||||
* @see <a href="http://www.iana.org/assignments/epp-repository-ids/epp-repository-ids.xhtml">
|
||||
* Extensible Provisioning Protocol (EPP) Repository Identifiers</a>
|
||||
*/
|
||||
@Provides
|
||||
@Config("contactAndHostRoidSuffix")
|
||||
public static String provideContactAndHostRoidSuffix(RegistryEnvironment environment) {
|
||||
return LocalTestConfig.CONTACT_AND_HOST_ROID_SUFFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* The e-mail address for questions about integrating with the registry. Used in the
|
||||
* "contact-us" section of the registrar console.
|
||||
|
@ -1007,4 +1020,10 @@ public final class ConfigModule {
|
|||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Config values used for local and unit test environments. */
|
||||
public static class LocalTestConfig {
|
||||
|
||||
public static final String CONTACT_AND_HOST_ROID_SUFFIX = "ROID";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,11 +158,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
|
|||
return Duration.millis(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContactAndHostRepositoryIdentifier() {
|
||||
return "ROID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getContactAutomaticTransferLength() {
|
||||
return standardDays(5);
|
||||
|
|
|
@ -118,15 +118,6 @@ public interface RegistryConfig {
|
|||
*/
|
||||
public String getGoogleAppsSendFromEmailAddress();
|
||||
|
||||
/**
|
||||
* Returns the roid suffix to be used for the roids of all contacts and hosts. E.g. a value of
|
||||
* "ROID" would end up creating roids that look like "ABC123-ROID".
|
||||
*
|
||||
* @see <a href="http://www.iana.org/assignments/epp-repository-ids/epp-repository-ids.xhtml">
|
||||
* Extensible Provisioning Protocol (EPP) Repository Identifiers</a>
|
||||
*/
|
||||
public String getContactAndHostRepositoryIdentifier();
|
||||
|
||||
/**
|
||||
* Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
|
||||
*
|
||||
|
|
|
@ -116,11 +116,6 @@ public class TestRegistryConfig implements RegistryConfig {
|
|||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContactAndHostRepositoryIdentifier() {
|
||||
return "ROID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getContactAutomaticTransferLength() {
|
||||
return standardDays(5);
|
||||
|
|
|
@ -18,10 +18,11 @@ import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
|||
import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist;
|
||||
import static google.registry.flows.contact.ContactFlowUtils.validateAsciiPostalInfo;
|
||||
import static google.registry.flows.contact.ContactFlowUtils.validateContactAgainstPolicy;
|
||||
import static google.registry.model.EppResourceUtils.createContactHostRoid;
|
||||
import static google.registry.model.EppResourceUtils.createRepoId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ExtensionManager;
|
||||
import google.registry.flows.FlowModule.ClientId;
|
||||
|
@ -56,6 +57,7 @@ public final class ContactCreateFlow implements TransactionalFlow {
|
|||
@Inject @TargetId String targetId;
|
||||
@Inject HistoryEntry.Builder historyBuilder;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject @Config("contactAndHostRoidSuffix") String roidSuffix;
|
||||
@Inject ContactCreateFlow() {}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +73,7 @@ public final class ContactCreateFlow implements TransactionalFlow {
|
|||
.setAuthInfo(command.getAuthInfo())
|
||||
.setCreationClientId(clientId)
|
||||
.setCurrentSponsorClientId(clientId)
|
||||
.setRepoId(createContactHostRoid(ObjectifyService.allocateId()))
|
||||
.setRepoId(createRepoId(ObjectifyService.allocateId(), roidSuffix))
|
||||
.setFaxNumber(command.getFax())
|
||||
.setVoiceNumber(command.getVoice())
|
||||
.setDisclose(command.getDisclose())
|
||||
|
|
|
@ -28,7 +28,7 @@ import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
|
|||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateSecDnsExtension;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRoid;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
||||
import static google.registry.model.EppResourceUtils.loadDomainApplication;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
|
@ -140,7 +140,7 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
|||
eppInput.getSingleExtension(AllocateCreateExtension.class);
|
||||
DomainApplication application =
|
||||
loadAndValidateApplication(allocateCreate.getApplicationRoid(), now);
|
||||
String repoId = createDomainRoid(ObjectifyService.allocateId(), registry.getTldStr());
|
||||
String repoId = createDomainRepoId(ObjectifyService.allocateId(), registry.getTldStr());
|
||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||
HistoryEntry historyEntry = buildHistory(repoId, period, now);
|
||||
entitiesToSave.add(historyEntry);
|
||||
|
|
|
@ -38,7 +38,7 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNo
|
|||
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAllowsLaunchFlows;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifySignedMarks;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRoid;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
|
@ -232,7 +232,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
|
|||
.setCreationTrid(trid)
|
||||
.setCreationClientId(clientId)
|
||||
.setCurrentSponsorClientId(clientId)
|
||||
.setRepoId(createDomainRoid(ObjectifyService.allocateId(), tld))
|
||||
.setRepoId(createDomainRepoId(ObjectifyService.allocateId(), tld))
|
||||
.setLaunchNotice(launchCreate == null ? null : launchCreate.getNotice())
|
||||
.setIdnTableName(idnTableName)
|
||||
.setPhase(launchCreate.getPhase())
|
||||
|
|
|
@ -36,7 +36,7 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyNotReserved;
|
|||
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifySignedMarks;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRoid;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
|
@ -233,7 +233,7 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
}
|
||||
SecDnsCreateExtension secDnsCreate =
|
||||
validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class));
|
||||
String repoId = createDomainRoid(ObjectifyService.allocateId(), registry.getTldStr());
|
||||
String repoId = createDomainRepoId(ObjectifyService.allocateId(), registry.getTldStr());
|
||||
DateTime registrationExpirationTime = leapSafeAddYears(now, years);
|
||||
HistoryEntry historyEntry = buildHistory(repoId, period, now);
|
||||
// Bill for the create.
|
||||
|
|
|
@ -19,7 +19,7 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist
|
|||
import static google.registry.flows.host.HostFlowUtils.lookupSuperordinateDomain;
|
||||
import static google.registry.flows.host.HostFlowUtils.validateHostName;
|
||||
import static google.registry.flows.host.HostFlowUtils.verifyDomainIsSameRegistrar;
|
||||
import static google.registry.model.EppResourceUtils.createContactHostRoid;
|
||||
import static google.registry.model.EppResourceUtils.createRepoId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
|
@ -27,6 +27,7 @@ import static google.registry.util.CollectionUtils.union;
|
|||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||
|
@ -81,6 +82,7 @@ public final class HostCreateFlow implements TransactionalFlow {
|
|||
@Inject HistoryEntry.Builder historyBuilder;
|
||||
@Inject DnsQueue dnsQueue;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject @Config("contactAndHostRoidSuffix") String roidSuffix;
|
||||
@Inject HostCreateFlow() {}
|
||||
|
||||
@Override
|
||||
|
@ -110,7 +112,7 @@ public final class HostCreateFlow implements TransactionalFlow {
|
|||
.setCurrentSponsorClientId(clientId)
|
||||
.setFullyQualifiedHostName(targetId)
|
||||
.setInetAddresses(command.getInetAddresses())
|
||||
.setRepoId(createContactHostRoid(ObjectifyService.allocateId()))
|
||||
.setRepoId(createRepoId(ObjectifyService.allocateId(), roidSuffix))
|
||||
.setSuperordinateDomain(
|
||||
superordinateDomain.isPresent() ? Key.create(superordinateDomain.get()) : null)
|
||||
.build();
|
||||
|
|
|
@ -27,7 +27,6 @@ import com.google.common.base.Function;
|
|||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Result;
|
||||
import com.googlecode.objectify.util.ResultNow;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.EppResource.Builder;
|
||||
import google.registry.model.EppResource.BuilderWithTransferData;
|
||||
import google.registry.model.EppResource.ForeignKeyedEppResource;
|
||||
|
@ -55,20 +54,13 @@ public final class EppResourceUtils {
|
|||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
|
||||
/** Returns the full domain repoId of the format HEX-TLD for the specified long id and tld. */
|
||||
public static String createDomainRoid(long repoId, String tld) {
|
||||
return createRoid(repoId, getRoidSuffixForTld(tld));
|
||||
/** Returns the full domain repoId in the format HEX-TLD for the specified long id and tld. */
|
||||
public static String createDomainRepoId(long repoId, String tld) {
|
||||
return createRepoId(repoId, getRoidSuffixForTld(tld));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full contact/host repoId of the format HEX-GOOGLE for the specified long repo id.
|
||||
*/
|
||||
public static String createContactHostRoid(long repoId) {
|
||||
return createRoid(
|
||||
repoId, RegistryEnvironment.get().config().getContactAndHostRepositoryIdentifier());
|
||||
}
|
||||
|
||||
private static String createRoid(long repoId, String roidSuffix) {
|
||||
/** Returns the full repoId in the format HEX-TLD for the specified long id and ROID suffix. */
|
||||
public static String createRepoId(long repoId, String roidSuffix) {
|
||||
// %X is uppercase hexadecimal.
|
||||
return String.format("%X-%s", repoId, roidSuffix);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@ import static com.google.common.base.Suppliers.memoize;
|
|||
import static com.google.common.collect.Iterables.toArray;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.config.ConfigModule.LocalTestConfig.CONTACT_AND_HOST_ROID_SUFFIX;
|
||||
import static google.registry.flows.ResourceFlowUtils.createTransferResponse;
|
||||
import static google.registry.model.EppResourceUtils.createContactHostRoid;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRoid;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
||||
import static google.registry.model.EppResourceUtils.createRepoId;
|
||||
import static google.registry.model.domain.launch.ApplicationStatus.VALIDATED;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
|
||||
|
@ -736,7 +737,7 @@ public class DatastoreHelper {
|
|||
|
||||
/** Returns a newly allocated, globally unique domain repoId of the format HEX-TLD. */
|
||||
public static String generateNewDomainRoid(String tld) {
|
||||
return createDomainRoid(ObjectifyService.allocateId(), tld);
|
||||
return createDomainRepoId(ObjectifyService.allocateId(), tld);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -744,7 +745,7 @@ public class DatastoreHelper {
|
|||
* HEX_TLD-ROID.
|
||||
*/
|
||||
public static String generateNewContactHostRoid() {
|
||||
return createContactHostRoid(ObjectifyService.allocateId());
|
||||
return createRepoId(ObjectifyService.allocateId(), CONTACT_AND_HOST_ROID_SUFFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue