Revert external ID cache
It make more sense to include the commit SHA-1 of the notes branch from which the external IDs have been read into the cache key. This makes it easier to implement this cache within a multimaster setup. However, obviously, we can include the commit SHA-1 of the notes branch into the cache key only after the external IDs have been migrated to NoteDb (because before this the notes branch does not exist yet). Revert the cache for now and re-add an improved version of the cache later with the change that implements the migration of the external IDs to NoteDb. This reverts the following commits: -2869caaf70
: Add cache for external ids -48d5c9b9aa
: Make ExternalIdCacheImpl.AllKey public -20e5507d46
: ExternalIdCache: Add method to get external IDs by account ID + scheme Change-Id: I589242aad32a9c70718542ba950c0a351c594e54 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -23,8 +23,10 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -35,28 +37,28 @@ import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class GetExternalIds implements RestReadView<AccountResource> {
|
||||
private final ExternalIdCache externalIdCache;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final Provider<CurrentUser> self;
|
||||
private final AuthConfig authConfig;
|
||||
|
||||
@Inject
|
||||
GetExternalIds(ExternalIdCache externalIdCache,
|
||||
GetExternalIds(Provider<ReviewDb> db,
|
||||
Provider<CurrentUser> self,
|
||||
AuthConfig authConfig) {
|
||||
this.externalIdCache = externalIdCache;
|
||||
this.db = db;
|
||||
this.self = self;
|
||||
this.authConfig = authConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountExternalIdInfo> apply(AccountResource resource)
|
||||
throws RestApiException {
|
||||
throws RestApiException, OrmException {
|
||||
if (self.get() != resource.getUser()) {
|
||||
throw new AuthException("not allowed to get external IDs");
|
||||
}
|
||||
|
||||
Collection<AccountExternalId> ids = externalIdCache.byAccount(
|
||||
resource.getUser().getAccountId());
|
||||
Collection<AccountExternalId> ids = db.get().accountExternalIds()
|
||||
.byAccount(resource.getUser().getAccountId()).toList();
|
||||
if (ids.isEmpty()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
Reference in New Issue
Block a user