Merge branch 'stable-2.15'

* stable-2.15:
  Documentation: Wrong field names in ChangeDetail JSON example
  Add /.bazel_path to .gitignore
  Add /plugins/cookbook-plugin/ to .gitignore
  AccountManager: Don't try to lookup external IDs from account index
  AccountManager#lookup: Don't use account index to resolve external ID

Change-Id: I97fa645bc007af7494e7a8139c657e0eef964be3
This commit is contained in:
David Pursehouse
2017-11-07 08:14:36 +09:00
3 changed files with 8 additions and 14 deletions

View File

@@ -35,11 +35,9 @@ import com.google.gerrit.server.account.externalids.ExternalIdsUpdate;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.group.db.GroupsUpdate;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.query.account.InternalAccountQuery;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.ArrayList;
@@ -68,7 +66,6 @@ public class AccountManager {
private final ChangeUserName.Factory changeUserNameFactory;
private final ProjectCache projectCache;
private final AtomicBoolean awaitsFirstAccountCheck;
private final Provider<InternalAccountQuery> accountQueryProvider;
private final ExternalIds externalIds;
private final ExternalIdsUpdate.Server externalIdsUpdateFactory;
private final GroupsUpdate.Factory groupsUpdateFactory;
@@ -87,7 +84,6 @@ public class AccountManager {
IdentifiedUser.GenericFactory userFactory,
ChangeUserName.Factory changeUserNameFactory,
ProjectCache projectCache,
Provider<InternalAccountQuery> accountQueryProvider,
ExternalIds externalIds,
ExternalIdsUpdate.Server externalIdsUpdateFactory,
GroupsUpdate.Factory groupsUpdateFactory,
@@ -103,7 +99,6 @@ public class AccountManager {
this.projectCache = projectCache;
this.awaitsFirstAccountCheck =
new AtomicBoolean(cfg.getBoolean("capability", "makeFirstUserAdmin", true));
this.accountQueryProvider = accountQueryProvider;
this.externalIds = externalIds;
this.externalIdsUpdateFactory = externalIdsUpdateFactory;
this.groupsUpdateFactory = groupsUpdateFactory;
@@ -115,11 +110,9 @@ public class AccountManager {
/** @return user identified by this external identity string */
public Optional<Account.Id> lookup(String externalId) throws AccountException {
try {
AccountState accountState = accountQueryProvider.get().oneByExternalId(externalId);
return accountState != null
? Optional.of(accountState.getAccount().getId())
: Optional.empty();
} catch (OrmException e) {
ExternalId extId = externalIds.get(ExternalId.Key.parse(externalId));
return extId != null ? Optional.of(extId.accountId()) : Optional.empty();
} catch (IOException | ConfigInvalidException e) {
throw new AccountException("Cannot lookup account " + externalId, e);
}
}