Rename "clientIdentifier" to "clientId" almost everywhere

It's best to be consistent and use the same thing everywhere.  "clientId" was
already used in more places and is shorter and no more ambiguous, so it's the
logical one to win out.

Note that this CL is almost solely a big Eclipse-assisted refactoring. There are
two places that I did not change clientIdentifier -- the actual entity field on
Registrar (though I did change all getters and setters), and the name of a
column on the exported registrar spreadsheet. Both would require data
migrations.

Also fixes a few minor nits discovered in touched files, including an incorrect
test in OfyFilterTest.java and some superfluous uses of String.format() when
calling checkArgument().

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133956465
This commit is contained in:
mcilwain
2016-09-22 14:30:05 -04:00
committed by Ben McIlwain
parent 0564bcdbc9
commit 4813ed392b
62 changed files with 208 additions and 200 deletions
@@ -41,7 +41,7 @@ final class CreateAnchorTenantCommand extends MutatingEppToolCommand implements
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = {"-n", "--domain_name"},
@@ -89,7 +89,7 @@ final class CreateAnchorTenantCommand extends MutatingEppToolCommand implements
setSoyTemplate(CreateAnchorTenantSoyInfo.getInstance(),
CreateAnchorTenantSoyInfo.CREATEANCHORTENANT);
addSoyRecord(clientIdentifier, new SoyMapData(
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"contactId", contact,
"reason", reason,
@@ -190,7 +190,7 @@ final class CreateAuctionCreditsCommand extends MutatingCommand {
Money totalAmount =
BigMoney.total(currency, creditMap.get(registrar)).toMoney(RoundingMode.UP);
System.out.printf("Total auction credit balance for %s: %s\n",
registrar.getClientIdentifier(), totalAmount);
registrar.getClientId(), totalAmount);
// Create the actual credit and initial credit balance.
RegistrarCredit credit = new RegistrarCredit.Builder()
@@ -35,7 +35,7 @@ final class CreateContactCommand extends MutatingEppToolCommand implements Gtech
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = {"-i", "--id"},
@@ -116,7 +116,7 @@ final class CreateContactCommand extends MutatingEppToolCommand implements Gtech
"Addresses must contain at most 3 street lines.");
setSoyTemplate(ContactCreateSoyInfo.getInstance(), ContactCreateSoyInfo.CONTACTCREATE);
addSoyRecord(clientIdentifier, new SoyMapData(
addSoyRecord(clientId, new SoyMapData(
"id", id,
"name", name,
"org", org,
@@ -33,7 +33,7 @@ final class CreateDomainCommand extends MutatingEppToolCommand implements GtechC
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = "--domain",
@@ -88,7 +88,7 @@ final class CreateDomainCommand extends MutatingEppToolCommand implements GtechC
checkArgument(ns == null || ns.size() <= 13, "There can be at most 13 nameservers.");
setSoyTemplate(DomainCreateSoyInfo.getInstance(), DomainCreateSoyInfo.DOMAINCREATE);
addSoyRecord(clientIdentifier, new SoyMapData(
addSoyRecord(clientId, new SoyMapData(
"domain", domain,
"period", period == null ? null : period.toString(),
"ns", ns,
@@ -36,7 +36,7 @@ final class CreateHostCommand extends MutatingEppToolCommand implements GtechCom
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as.",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = "--host",
@@ -67,7 +67,7 @@ final class CreateHostCommand extends MutatingEppToolCommand implements GtechCom
}
}
addSoyRecord(
clientIdentifier,
clientId,
new SoyMapData(
"hostname", hostName,
"ipv4addresses", ipv4Addresses.build(),
@@ -242,7 +242,7 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
/** Returns the existing registrar (for update) or null (for creates). */
@Nullable
abstract Registrar getOldRegistrar(String clientIdentifier);
abstract Registrar getOldRegistrar(String clientId);
protected void initRegistrarCommand() throws Exception {}
@@ -250,10 +250,10 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
protected final void init() throws Exception {
initRegistrarCommand();
DateTime now = DateTime.now(UTC);
for (String clientIdentifier : mainParameters) {
Registrar oldRegistrar = getOldRegistrar(clientIdentifier);
for (String clientId : mainParameters) {
Registrar oldRegistrar = getOldRegistrar(clientId);
Registrar.Builder builder = (oldRegistrar == null)
? new Registrar.Builder().setClientIdentifier(clientIdentifier)
? new Registrar.Builder().setClientId(clientId)
: oldRegistrar.asBuilder();
if (!isNullOrEmpty(password)) {
@@ -341,7 +341,7 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
checkState(balance.isZero(),
"Refusing to change billing method on Registrar '%s' from %s to %s"
+ " because current balance is non-zero: %s",
clientIdentifier, oldRegistrar.getBillingMethod(), billingMethod, balances);
clientId, oldRegistrar.getBillingMethod(), billingMethod, balances);
}
}
builder.setBillingMethod(billingMethod);
@@ -78,30 +78,27 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand
@Nullable
@Override
Registrar getOldRegistrar(final String clientIdentifier) {
checkArgument(clientIdentifier.length() >= 3,
String.format("Client identifier (%s) is too short", clientIdentifier));
checkArgument(clientIdentifier.length() <= 16,
String.format("Client identifier (%s) is too long", clientIdentifier));
Registrar getOldRegistrar(final String clientId) {
checkArgument(clientId.length() >= 3, "Client identifier (%s) is too short", clientId);
checkArgument(clientId.length() <= 16, "Client identifier (%s) is too long", clientId);
if (Registrar.Type.REAL.equals(registrarType)) {
checkArgument(clientIdentifier.equals(normalizeClientId(clientIdentifier)),
String.format(
"Client identifier (%s) can only contain lowercase letters, numbers, and hyphens",
clientIdentifier));
checkArgument(
clientId.equals(normalizeClientId(clientId)),
"Client identifier (%s) can only contain lowercase letters, numbers, and hyphens",
clientId);
}
checkState(Registrar.loadByClientId(clientIdentifier) == null,
"Registrar %s already exists", clientIdentifier);
checkState(Registrar.loadByClientId(clientId) == null, "Registrar %s already exists", clientId);
List<Registrar> collisions =
newArrayList(filter(Registrar.loadAll(), new Predicate<Registrar>() {
@Override
public boolean apply(Registrar registrar) {
return normalizeClientId(registrar.getClientIdentifier()).equals(clientIdentifier);
return normalizeClientId(registrar.getClientId()).equals(clientId);
}}));
if (!collisions.isEmpty()) {
throw new IllegalArgumentException(String.format(
"The registrar client identifier %s normalizes identically to existing registrar %s",
clientIdentifier,
collisions.get(0).getClientIdentifier()));
clientId,
collisions.get(0).getClientId()));
}
return null;
}
@@ -118,7 +115,7 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand
try {
// We know it is safe to use the only main parameter here because initRegistrarCommand has
// already verified that there is only one, and getOldRegistrar has already verified that a
// registrar with this clientIdentifier doesn't already exist.
// registrar with this clientId doesn't already exist.
CreateRegistrarGroupsCommand.executeOnServer(connection, getOnlyElement(mainParameters));
} catch (Exception e) {
return "\nRegistrar created, but groups creation failed with error:\n" + e;
@@ -72,10 +72,10 @@ public class CreateRegistrarGroupsCommand extends ConfirmingCommand
}
/** Calls the server endpoint to create groups for the specified registrar client id. */
static void executeOnServer(Connection connection, String clientIdentifier) throws IOException {
static void executeOnServer(Connection connection, String clientId) throws IOException {
connection.send(
CreateGroupsAction.PATH,
ImmutableMap.of(CreateGroupsAction.CLIENT_ID_PARAM, clientIdentifier),
ImmutableMap.of(CreateGroupsAction.CLIENT_ID_PARAM, clientId),
MediaType.PLAIN_TEXT_UTF_8,
new byte[0]);
}
@@ -85,7 +85,7 @@ public class CreateRegistrarGroupsCommand extends ConfirmingCommand
for (Registrar registrar : registrars) {
connection.send(
CreateGroupsAction.PATH,
ImmutableMap.of(CreateGroupsAction.CLIENT_ID_PARAM, registrar.getClientIdentifier()),
ImmutableMap.of(CreateGroupsAction.CLIENT_ID_PARAM, registrar.getClientId()),
MediaType.PLAIN_TEXT_UTF_8,
new byte[0]);
}
@@ -28,7 +28,7 @@ final class DeleteDomainCommand extends MutatingEppToolCommand implements GtechC
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = {"-n", "--domain_name"},
@@ -51,7 +51,7 @@ final class DeleteDomainCommand extends MutatingEppToolCommand implements GtechC
@Override
protected void initMutatingEppToolCommand() {
setSoyTemplate(DeleteDomainSoyInfo.getInstance(), DeleteDomainSoyInfo.DELETEDOMAIN);
addSoyRecord(clientIdentifier, new SoyMapData(
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"reason", reason,
"requestedByRegistrar", requestedByRegistrar));
@@ -32,7 +32,7 @@ final class DomainApplicationInfoCommand extends EppToolCommand implements Gtech
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = {"--id"},
@@ -60,7 +60,7 @@ final class DomainApplicationInfoCommand extends EppToolCommand implements Gtech
setSoyTemplate(
DomainApplicationInfoSoyInfo.getInstance(),
DomainApplicationInfoSoyInfo.DOMAINAPPLICATIONINFO);
addSoyRecord(clientIdentifier, new SoyMapData(
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"id", id,
"phase", launchPhase.getPhase(),
@@ -31,7 +31,7 @@ final class DomainCheckClaimsCommand extends EppToolCommand implements GtechComm
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
description = "Domain(s) to check.",
@@ -44,7 +44,7 @@ final class DomainCheckClaimsCommand extends EppToolCommand implements GtechComm
for (Collection<String> values : domainNameMap.asMap().values()) {
setSoyTemplate(
DomainCheckClaimsSoyInfo.getInstance(), DomainCheckClaimsSoyInfo.DOMAINCHECKCLAIMS);
addSoyRecord(clientIdentifier, new SoyMapData("domainNames", values));
addSoyRecord(clientId, new SoyMapData("domainNames", values));
}
}
}
@@ -31,7 +31,7 @@ final class DomainCheckCommand extends EppToolCommand implements GtechCommand {
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
description = "List of domains to check.",
@@ -43,7 +43,7 @@ final class DomainCheckCommand extends EppToolCommand implements GtechCommand {
Multimap<String, String> domainNameMap = validateAndGroupDomainNamesByTld(mainParameters);
for (Collection<String> values : domainNameMap.asMap().values()) {
setSoyTemplate(DomainCheckSoyInfo.getInstance(), DomainCheckSoyInfo.DOMAINCHECK);
addSoyRecord(clientIdentifier, new SoyMapData("domainNames", values));
addSoyRecord(clientId, new SoyMapData("domainNames", values));
}
}
}
@@ -31,7 +31,7 @@ final class DomainCheckFeeCommand extends EppToolCommand implements GtechCommand
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
description = "Domain(s) to check.",
@@ -43,7 +43,7 @@ final class DomainCheckFeeCommand extends EppToolCommand implements GtechCommand
Multimap<String, String> domainNameMap = validateAndGroupDomainNamesByTld(mainParameters);
for (Collection<String> values : domainNameMap.asMap().values()) {
setSoyTemplate(DomainCheckFeeSoyInfo.getInstance(), DomainCheckFeeSoyInfo.DOMAINCHECKFEE);
addSoyRecord(clientIdentifier, new SoyMapData("domainNames", values));
addSoyRecord(clientId, new SoyMapData("domainNames", values));
}
}
}
@@ -141,11 +141,11 @@ abstract class EppToolCommand extends ConfirmingCommand implements ServerSideCom
for (XmlEppParameters command : commands) {
Map<String, Object> params = new HashMap<>();
params.put("dryRun", dryRun);
params.put("clientIdentifier", command.clientId);
params.put("clientId", command.clientId);
params.put("superuser", superuser);
params.put("xml", URLEncoder.encode(command.xml, UTF_8.toString()));
String requestBody = Joiner.on('&').withKeyValueSeparator("=")
.join(filterValues(params, notNull()));
String requestBody =
Joiner.on('&').withKeyValueSeparator("=").join(filterValues(params, notNull()));
responses.add(nullToEmpty(connection.send(
"/_dr/epptool",
ImmutableMap.<String, String>of(),
@@ -38,7 +38,7 @@ final class ExecuteEppCommand extends MutatingEppToolCommand {
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@NonFinalForTesting
private static InputStream stdin = System.in;
@@ -47,10 +47,10 @@ final class ExecuteEppCommand extends MutatingEppToolCommand {
protected void initMutatingEppToolCommand() throws IOException {
if (mainParameters.isEmpty()) {
addXmlCommand(
clientIdentifier, CharStreams.toString(new InputStreamReader(stdin, UTF_8)));
clientId, CharStreams.toString(new InputStreamReader(stdin, UTF_8)));
} else {
for (String command : mainParameters) {
addXmlCommand(clientIdentifier, Files.toString(new File(command), UTF_8));
addXmlCommand(clientId, Files.toString(new File(command), UTF_8));
}
}
}
@@ -240,7 +240,7 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand, GtechCommand
// Registrar Address 2|Registrar City|Registrar Province|Registrar Postal Code|
// Registrar Country|Registrar Email|Registrar Telephone
return Joiner.on('|').join(ImmutableList.of(
registrar.getClientIdentifier(),
registrar.getClientId(),
contact.isPresent() ? contact.get().getName() : "N/A",
nullToEmpty(registrar.getRegistrarName()),
Iterables.getFirst(street, ""),
@@ -34,8 +34,8 @@ final class GetRegistrarCommand implements RemoteApiCommand, GtechCommand {
@Override
public void run() {
for (String clientIdentifier : mainParameters) {
Registrar registrar = Registrar.loadByClientId(clientIdentifier);
for (String clientId : mainParameters) {
Registrar registrar = Registrar.loadByClientId(clientId);
checkState(registrar != null, "Registrar does not exist");
System.out.println(registrar);
@@ -43,7 +43,7 @@ final class ListCreditsCommand implements RemoteApiCommand, GtechCommand {
for (Registrar registrar : Registrar.loadAll()) {
ImmutableList<String> creditStrings = createCreditStrings(registrar);
if (!creditStrings.isEmpty()) {
System.out.println(registrar.getClientIdentifier());
System.out.println(registrar.getClientId());
System.out.print(Joiner.on("").join(creditStrings));
System.out.println();
}
@@ -139,9 +139,9 @@ final class RegistrarContactCommand extends MutatingCommand implements GtechComm
protected void init() throws Exception {
checkArgument(mainParameters.size() == 1,
"Must specify exactly one client identifier: %s", ImmutableList.copyOf(mainParameters));
String clientIdentifier = mainParameters.get(0);
Registrar registrar = checkNotNull(
Registrar.loadByClientId(clientIdentifier), "Registrar %s not found", clientIdentifier);
String clientId = mainParameters.get(0);
Registrar registrar =
checkNotNull(Registrar.loadByClientId(clientId), "Registrar %s not found", clientId);
contactTypes =
newHashSet(
transform(
@@ -24,9 +24,10 @@ import google.registry.tools.Command.GtechCommand;
@Parameters(separators = " =", commandDescription = "Update registrar account(s)")
final class UpdateRegistrarCommand extends CreateOrUpdateRegistrarCommand
implements GtechCommand {
@Override
Registrar getOldRegistrar(String clientIdentifier) {
Registrar getOldRegistrar(String clientId) {
return checkNotNull(
Registrar.loadByClientId(clientIdentifier), "Registrar %s not found", clientIdentifier);
Registrar.loadByClientId(clientId), "Registrar %s not found", clientId);
}
}
@@ -40,7 +40,7 @@ final class UpdateServerLocksCommand extends MutatingEppToolCommand implements G
names = {"-c", "--client"},
description = "Client identifier of the registrar to execute the command as",
required = true)
String clientIdentifier;
String clientId;
@Parameter(
names = {"-n", "--domain_name"},
@@ -105,7 +105,7 @@ final class UpdateServerLocksCommand extends MutatingEppToolCommand implements G
"Add and remove actions are both empty");
setSoyTemplate(
UpdateServerLocksSoyInfo.getInstance(), UpdateServerLocksSoyInfo.UPDATESERVERLOCKS);
addSoyRecord(clientIdentifier, new SoyMapData(
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"locksToApply", valuesToApply,
"locksToRemove", valuesToRemove,
@@ -41,7 +41,7 @@ final class ValidateLoginCredentialsCommand implements RemoteApiCommand, GtechCo
names = {"-c", "--client"},
description = "Client identifier of the registrar to test",
required = true)
private String clientIdentifier;
private String clientId;
@Parameter(
names = {"-p", "--password"},
@@ -76,7 +76,7 @@ final class ValidateLoginCredentialsCommand implements RemoteApiCommand, GtechCo
clientCertificateHash = getCertificateHash(
loadCertificate(new String(Files.readAllBytes(clientCertificatePath), US_ASCII)));
}
Registrar registrar = Registrar.loadByClientId(clientIdentifier);
Registrar registrar = Registrar.loadByClientId(clientId);
new TlsCredentials(clientCertificateHash, Optional.of(clientIpAddress), null)
.validate(registrar, password);
checkState(!registrar.getState().equals(Registrar.State.PENDING), "Account pending");
@@ -108,7 +108,7 @@ final class VerifyOteCommand implements ServerSideCommand, GtechCommand {
.transform(new Function<Registrar, String>() {
@Override
public String apply(Registrar registrar) {
String name = registrar.getClientIdentifier();
String name = registrar.getClientId();
// Look for names of the form "regname-1", "regname-2", etc. and strip the -# suffix.
String replacedName = name.replaceFirst("^(.*)-[1234]$", "$1");
// Check if any replacement happened, and thus whether the name matches the format.
@@ -73,7 +73,7 @@ public class CreateGroupsAction implements Runnable {
public Optional<Exception> apply(Type type) {
try {
String groupKey = getGroupEmailAddressForContactType(
registrar.getClientIdentifier(), type, publicDomainName);
registrar.getClientId(), type, publicDomainName);
String parentGroup =
getGroupEmailAddressForContactType("registrar", type, publicDomainName);
// Creates the group, then adds it as a member to the global registrar group for