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 08:31:00 -07:00 committed by Ben McIlwain
parent 0564bcdbc9
commit 4813ed392b
62 changed files with 208 additions and 200 deletions

View file

@ -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;