Merge branch 'stable-2.15'
* stable-2.15: Keep "refs/publish/*" as a synonym of "refs/for/*" Update git submodules Update JGit to 4.9.0.201710071750-r InitAdminUser: Reindex admin group after adding the user Fall-back to loading groups from ReviewDb if group index is not available Change-Id: Id386126b1e277aa7101ba1ab1a4438becf0a39de
This commit is contained in:
@@ -17,6 +17,7 @@ package com.google.gerrit.pgm.init;
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
import com.google.gerrit.extensions.client.AuthType;
|
import com.google.gerrit.extensions.client.AuthType;
|
||||||
import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider;
|
import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider;
|
||||||
@@ -31,8 +32,11 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gerrit.server.account.AccountState;
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||||
import com.google.gerrit.server.config.AllUsersName;
|
import com.google.gerrit.server.config.AllUsersName;
|
||||||
|
import com.google.gerrit.server.group.InternalGroup;
|
||||||
import com.google.gerrit.server.index.account.AccountIndex;
|
import com.google.gerrit.server.index.account.AccountIndex;
|
||||||
import com.google.gerrit.server.index.account.AccountIndexCollection;
|
import com.google.gerrit.server.index.account.AccountIndexCollection;
|
||||||
|
import com.google.gerrit.server.index.group.GroupIndex;
|
||||||
|
import com.google.gerrit.server.index.group.GroupIndexCollection;
|
||||||
import com.google.gwtorm.server.SchemaFactory;
|
import com.google.gwtorm.server.SchemaFactory;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -55,7 +59,8 @@ public class InitAdminUser implements InitStep {
|
|||||||
private final SequencesOnInit sequencesOnInit;
|
private final SequencesOnInit sequencesOnInit;
|
||||||
private final GroupsOnInit groupsOnInit;
|
private final GroupsOnInit groupsOnInit;
|
||||||
private SchemaFactory<ReviewDb> dbFactory;
|
private SchemaFactory<ReviewDb> dbFactory;
|
||||||
private AccountIndexCollection indexCollection;
|
private AccountIndexCollection accountIndexCollection;
|
||||||
|
private GroupIndexCollection groupIndexCollection;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
InitAdminUser(
|
InitAdminUser(
|
||||||
@@ -86,8 +91,13 @@ public class InitAdminUser implements InitStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(optional = true)
|
@Inject(optional = true)
|
||||||
void set(AccountIndexCollection indexCollection) {
|
void set(AccountIndexCollection accountIndexCollection) {
|
||||||
this.indexCollection = indexCollection;
|
this.accountIndexCollection = accountIndexCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(optional = true)
|
||||||
|
void set(GroupIndexCollection groupIndexCollection) {
|
||||||
|
this.groupIndexCollection = groupIndexCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,9 +148,15 @@ public class InitAdminUser implements InitStep {
|
|||||||
Collections.singleton(adminGroup.getGroupUUID()),
|
Collections.singleton(adminGroup.getGroupUUID()),
|
||||||
extIds,
|
extIds,
|
||||||
new HashMap<>());
|
new HashMap<>());
|
||||||
for (AccountIndex accountIndex : indexCollection.getWriteIndexes()) {
|
for (AccountIndex accountIndex : accountIndexCollection.getWriteIndexes()) {
|
||||||
accountIndex.replace(as);
|
accountIndex.replace(as);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InternalGroup adminInternalGroup =
|
||||||
|
InternalGroup.create(adminGroup, ImmutableSet.of(id), ImmutableSet.of());
|
||||||
|
for (GroupIndex groupIndex : groupIndexCollection.getWriteIndexes()) {
|
||||||
|
groupIndex.replace(adminInternalGroup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,8 @@ public class AccountCacheImpl implements AccountCache {
|
|||||||
private ImmutableSet<AccountGroup.UUID> getGroupsWithMember(ReviewDb db, Account.Id memberId)
|
private ImmutableSet<AccountGroup.UUID> getGroupsWithMember(ReviewDb db, Account.Id memberId)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
Stream<InternalGroup> internalGroupStream;
|
Stream<InternalGroup> internalGroupStream;
|
||||||
if (groupIndexProvider.get().getSchema().hasField(GroupField.MEMBER)) {
|
if (groupIndexProvider.get() != null
|
||||||
|
&& groupIndexProvider.get().getSchema().hasField(GroupField.MEMBER)) {
|
||||||
internalGroupStream = groupQueryProvider.get().byMember(memberId).stream();
|
internalGroupStream = groupQueryProvider.get().byMember(memberId).stream();
|
||||||
} else {
|
} else {
|
||||||
internalGroupStream =
|
internalGroupStream =
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gerrit.server.cache.CacheModule;
|
import com.google.gerrit.server.cache.CacheModule;
|
||||||
import com.google.gerrit.server.group.Groups;
|
import com.google.gerrit.server.group.Groups;
|
||||||
import com.google.gerrit.server.group.InternalGroup;
|
import com.google.gerrit.server.group.InternalGroup;
|
||||||
|
import com.google.gerrit.server.index.group.GroupIndexCollection;
|
||||||
import com.google.gerrit.server.index.group.GroupIndexer;
|
import com.google.gerrit.server.index.group.GroupIndexer;
|
||||||
import com.google.gerrit.server.query.group.InternalGroupQuery;
|
import com.google.gerrit.server.query.group.InternalGroupQuery;
|
||||||
import com.google.gwtorm.server.SchemaFactory;
|
import com.google.gwtorm.server.SchemaFactory;
|
||||||
@@ -147,16 +148,32 @@ public class GroupCacheImpl implements GroupCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class ByIdLoader extends CacheLoader<AccountGroup.Id, Optional<InternalGroup>> {
|
static class ByIdLoader extends CacheLoader<AccountGroup.Id, Optional<InternalGroup>> {
|
||||||
|
private final SchemaFactory<ReviewDb> schema;
|
||||||
|
private final Groups groups;
|
||||||
|
private final boolean hasGroupIndex;
|
||||||
private final Provider<InternalGroupQuery> groupQueryProvider;
|
private final Provider<InternalGroupQuery> groupQueryProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ByIdLoader(Provider<InternalGroupQuery> groupQueryProvider) {
|
ByIdLoader(
|
||||||
|
SchemaFactory<ReviewDb> schema,
|
||||||
|
Groups groups,
|
||||||
|
GroupIndexCollection groupIndexCollection,
|
||||||
|
Provider<InternalGroupQuery> groupQueryProvider) {
|
||||||
|
this.schema = schema;
|
||||||
|
this.groups = groups;
|
||||||
|
this.hasGroupIndex = groupIndexCollection.getSearchIndex() != null;
|
||||||
this.groupQueryProvider = groupQueryProvider;
|
this.groupQueryProvider = groupQueryProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<InternalGroup> load(AccountGroup.Id key) throws Exception {
|
public Optional<InternalGroup> load(AccountGroup.Id key) throws Exception {
|
||||||
return groupQueryProvider.get().byId(key);
|
if (hasGroupIndex) {
|
||||||
|
return groupQueryProvider.get().byId(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (ReviewDb db = schema.open()) {
|
||||||
|
return groups.getGroup(db, key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,29 @@ import java.util.stream.Stream;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class Groups {
|
public class Groups {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@code AccountGroup} for the specified ID if it exists.
|
||||||
|
*
|
||||||
|
* @param db the {@code ReviewDb} instance to use for lookups
|
||||||
|
* @param groupId the ID of the group
|
||||||
|
* @return the found {@code AccountGroup} if it exists, or else an empty {@code Optional}
|
||||||
|
* @throws OrmException if the group couldn't be retrieved from ReviewDb
|
||||||
|
*/
|
||||||
|
public Optional<InternalGroup> getGroup(ReviewDb db, AccountGroup.Id groupId)
|
||||||
|
throws OrmException, NoSuchGroupException {
|
||||||
|
Optional<AccountGroup> accountGroup = Optional.ofNullable(db.accountGroups().get(groupId));
|
||||||
|
|
||||||
|
if (!accountGroup.isPresent()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountGroup.UUID groupUuid = accountGroup.get().getGroupUUID();
|
||||||
|
ImmutableSet<Account.Id> members = getMembers(db, groupUuid).collect(toImmutableSet());
|
||||||
|
ImmutableSet<AccountGroup.UUID> subgroups =
|
||||||
|
getSubgroups(db, groupUuid).collect(toImmutableSet());
|
||||||
|
return accountGroup.map(group -> InternalGroup.create(group, members, subgroups));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@code InternalGroup} for the specified UUID if it exists.
|
* Returns the {@code InternalGroup} for the specified UUID if it exists.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "MAVEN_CENTRAL", "maven_jar")
|
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "MAVEN_CENTRAL", "maven_jar")
|
||||||
|
|
||||||
_JGIT_VERS = "4.8.0.201706111038-r.71-g45da0fc6f"
|
_JGIT_VERS = "4.9.0.201710071750-r"
|
||||||
|
|
||||||
_DOC_VERS = "4.8.0.201706111038-r" # Set to _JGIT_VERS unless using a snapshot
|
_DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot
|
||||||
|
|
||||||
JGIT_DOC_URL = "http://download.eclipse.org/jgit/site/" + _DOC_VERS + "/apidocs"
|
JGIT_DOC_URL = "http://download.eclipse.org/jgit/site/" + _DOC_VERS + "/apidocs"
|
||||||
|
|
||||||
_JGIT_REPO = GERRIT # Leave here even if set to MAVEN_CENTRAL.
|
_JGIT_REPO = MAVEN_CENTRAL # Leave here even if set to MAVEN_CENTRAL.
|
||||||
|
|
||||||
# set this to use a local version.
|
# set this to use a local version.
|
||||||
# "/home/<user>/projects/jgit"
|
# "/home/<user>/projects/jgit"
|
||||||
@@ -26,28 +26,28 @@ def jgit_maven_repos():
|
|||||||
name = "jgit_lib",
|
name = "jgit_lib",
|
||||||
artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
|
artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
|
||||||
repository = _JGIT_REPO,
|
repository = _JGIT_REPO,
|
||||||
sha1 = "7248b0a7d7f76dd4f7e55ed081b981cf4d8aa26e",
|
sha1 = "69d8510b335d4d33d551a133505a4141311f970a",
|
||||||
src_sha1 = "6ed203c95decc3f795f44ca17149e7554b92212d",
|
src_sha1 = "6fd1eb331447b6163898b4d10aa769e2ac193740",
|
||||||
unsign = True,
|
unsign = True,
|
||||||
)
|
)
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = "jgit_servlet",
|
name = "jgit_servlet",
|
||||||
artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
|
artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
|
||||||
repository = _JGIT_REPO,
|
repository = _JGIT_REPO,
|
||||||
sha1 = "f21fc0c651cc9475db92061432d919ba28b7a7ad",
|
sha1 = "93fb0075988b9c6bb97c725c03706f2341965b6b",
|
||||||
unsign = True,
|
unsign = True,
|
||||||
)
|
)
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = "jgit_archive",
|
name = "jgit_archive",
|
||||||
artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
|
artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
|
||||||
repository = _JGIT_REPO,
|
repository = _JGIT_REPO,
|
||||||
sha1 = "0f179321f527840dfc8ca79894eba2f6b255dbab",
|
sha1 = "a15aee805c758516ad7e9fa3f16e27bb9f4a1c2e",
|
||||||
)
|
)
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = "jgit_junit",
|
name = "jgit_junit",
|
||||||
artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
|
artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
|
||||||
repository = _JGIT_REPO,
|
repository = _JGIT_REPO,
|
||||||
sha1 = "7e5225064cf14115bddaae9448246c83c89f78ad",
|
sha1 = "b6e712e743ea5798134f54547ae80456fad07f76",
|
||||||
unsign = True,
|
unsign = True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Submodule plugins/replication updated: 93ab1609a4...2540766109
Reference in New Issue
Block a user