Automatically create the admin group on database creation
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -25,6 +25,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface GroupAdminService extends RemoteJsonService {
|
||||
/** Special group, which must not be renamed as its "blessed". */
|
||||
public static final AccountGroup.NameKey ADMIN_GROUP = new AccountGroup.NameKey("admin");
|
||||
|
||||
@SignInRequired
|
||||
void ownedGroups(AsyncCallback<List<AccountGroup>> callback);
|
||||
|
||||
|
@@ -184,8 +184,7 @@ public class GroupAdminServiceImpl extends BaseServiceImplementation implements
|
||||
}
|
||||
|
||||
private static boolean amAdmin(final ReviewDb db) throws OrmException {
|
||||
final AccountGroup admin =
|
||||
db.accountGroups().get(new AccountGroup.NameKey("admin"));
|
||||
final AccountGroup admin = db.accountGroups().get(ADMIN_GROUP);
|
||||
if (admin == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -14,9 +14,11 @@
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.gerrit.client.admin.GroupAdminService;
|
||||
import com.google.gerrit.client.data.ApprovalType;
|
||||
import com.google.gerrit.client.data.GerritConfig;
|
||||
import com.google.gerrit.client.data.GitwebLink;
|
||||
import com.google.gerrit.client.reviewdb.AccountGroup;
|
||||
import com.google.gerrit.client.reviewdb.ApprovalCategory;
|
||||
import com.google.gerrit.client.reviewdb.ApprovalCategoryValue;
|
||||
import com.google.gerrit.client.reviewdb.ReviewDb;
|
||||
@@ -153,6 +155,11 @@ public class GerritServer {
|
||||
s.accountPrivateKey = SignedToken.generateRandomKey();
|
||||
s.sshdPort = 29418;
|
||||
c.systemConfig().insert(Collections.singleton(s));
|
||||
|
||||
final AccountGroup admin =
|
||||
new AccountGroup(GroupAdminService.ADMIN_GROUP, new AccountGroup.Id(c
|
||||
.nextAccountGroupId()));
|
||||
c.accountGroups().insert(Collections.singleton(admin));
|
||||
}
|
||||
|
||||
private void initVerifiedCategory(final ReviewDb c) throws OrmException {
|
||||
|
Reference in New Issue
Block a user