Merge "Merge branch 'stable-2.14'"

This commit is contained in:
David Pursehouse
2017-07-05 01:46:28 +00:00
committed by Gerrit Code Review
3 changed files with 25 additions and 5 deletions

View File

@@ -28,9 +28,11 @@ The program will produce errors if there are accounts that have the
same local username, but with different case. In this case the local
username for these accounts is not converted to lower case.
This task can run in the background concurrently to the server if the
database is MySQL or PostgreSQL. If the database is H2, this task
must be run by itself.
After all usernames have been migrated, the link:pgm-reindex.html[
reindex] program is automatically invoked to reindex all accounts.
This task cannot run in the background concurrently to the server;
it must be run by itself.
== OPTIONS

View File

@@ -23,12 +23,14 @@ import com.google.gerrit.server.account.externalids.DisabledExternalIdCache;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds;
import com.google.gerrit.server.account.externalids.ExternalIdsBatchUpdate;
import com.google.gerrit.server.index.account.AccountSchemaDefinitions;
import com.google.gerrit.server.schema.SchemaVersionCheck;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
import java.util.Collection;
import java.util.Locale;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.TextProgressMonitor;
/** Converts the local username for all accounts to lower case */
@@ -69,8 +71,10 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
externalIdsBatchUpdate.commit("Convert local usernames to lower case");
monitor.endTask();
int exitCode = reindexAccounts();
manager.stop();
return 0;
return exitCode;
}
private void convertLocalUserToLowerCase(ExternalId extId) {
@@ -89,4 +93,17 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
}
}
}
private int reindexAccounts() throws Exception {
monitor.beginTask("Reindex accounts", ProgressMonitor.UNKNOWN);
String[] reindexArgs = {
"--site-path", getSitePath().toString(), "--index", AccountSchemaDefinitions.NAME
};
System.out.println("Migration complete, reindexing accounts with:");
System.out.println(" reindex " + String.join(" ", reindexArgs));
Reindex reindexPgm = new Reindex();
int exitCode = reindexPgm.main(reindexArgs);
monitor.endTask();
return exitCode;
}
}

View File

@@ -36,9 +36,10 @@ public class AccountSchemaDefinitions extends SchemaDefinitions<AccountState> {
static final Schema<AccountState> V5 = schema(V4, AccountField.PREFERRED_EMAIL);
public static final String NAME = "accounts";
public static final AccountSchemaDefinitions INSTANCE = new AccountSchemaDefinitions();
private AccountSchemaDefinitions() {
super("accounts", AccountState.class);
super(NAME, AccountState.class);
}
}