use of com.google.gerrit.server.account.AccountConfig in project gerrit by GerritCodeReview.
the class AccountValidator method loadAccount.
private Optional<Account> loadAccount(Account.Id accountId, Repository allUsersRepo, RevWalk rw, ObjectId commit, @Nullable ImmutableList.Builder<String> messages) throws IOException, ConfigInvalidException {
rw.reset();
AccountConfig accountConfig = new AccountConfig(accountId, allUsersName, allUsersRepo);
accountConfig.load(allUsersName, rw, commit);
if (messages != null) {
messages.addAll(accountConfig.getValidationErrors().stream().map(ValidationError::getMessage).collect(toSet()));
}
return accountConfig.getLoadedAccount();
}
use of com.google.gerrit.server.account.AccountConfig in project gerrit by GerritCodeReview.
the class AccountIndexerIT method updateAccountWithoutCacheOrIndex.
private void updateAccountWithoutCacheOrIndex(Account.Id accountId, AccountDelta accountDelta) throws IOException, ConfigInvalidException {
try (Repository allUsersRepo = repoManager.openRepository(allUsersName);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsersName, allUsersRepo)) {
PersonIdent ident = serverIdent.get();
md.getCommitBuilder().setAuthor(ident);
md.getCommitBuilder().setCommitter(ident);
AccountConfig accountConfig = new AccountConfig(accountId, allUsersName, allUsersRepo).load();
accountConfig.setAccountDelta(accountDelta);
accountConfig.commit(md);
}
}
use of com.google.gerrit.server.account.AccountConfig in project gerrit by GerritCodeReview.
the class AbstractQueryAccountsTest method reindex.
// reindex permissions are tested by {@link AccountIT#reindexPermissions}
@Test
public void reindex() throws Exception {
AccountInfo user1 = newAccountWithFullName("tester", "Test Usre");
// update account without reindex so that account index is stale
Account.Id accountId = Account.id(user1._accountId);
String newName = "Test User";
try (Repository repo = repoManager.openRepository(allUsers)) {
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsers, repo);
PersonIdent ident = serverIdent.get();
md.getCommitBuilder().setAuthor(ident);
md.getCommitBuilder().setCommitter(ident);
new AccountConfig(accountId, allUsers, repo).load().setAccountDelta(AccountDelta.builder().setFullName(newName).build()).commit(md);
}
// Querying for the account here will not result in a stale document because
// we load AccountStates from the cache after reading documents from the index
// which means we always read fresh data when matching.
//
// Reindex document
gApi.accounts().id(user1.username).index();
assertQuery("name:" + quote(user1.name));
assertQuery("name:" + quote(newName), user1);
}
Aggregations