use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.
the class Schema_125 method migrateData.
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
try (Repository git = repoManager.openRepository(allUsersName);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsersName, git)) {
ProjectConfig config = ProjectConfig.read(md);
config.getAccessSection(RefNames.REFS_USERS + "*", true).remove(new Permission(Permission.READ));
GroupReference registered = systemGroupBackend.getGroup(REGISTERED_USERS);
AccessSection users = config.getAccessSection(RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}", true);
grant(config, users, Permission.READ, true, registered);
grant(config, users, Permission.PUSH, true, registered);
grant(config, users, Permission.SUBMIT, true, registered);
for (LabelType lt : getLabelTypes(config)) {
if ("Code-Review".equals(lt.getName()) || "Verified".equals(lt.getName())) {
grant(config, users, lt, lt.getMin().getValue(), lt.getMax().getValue(), registered);
}
}
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
md.setMessage(COMMIT_MSG);
config.commit(md);
} catch (ConfigInvalidException | IOException ex) {
throw new OrmException(ex);
}
}
use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.
the class Schema_126 method migrateData.
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
try (Repository git = repoManager.openRepository(allUsersName);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsersName, git)) {
ProjectConfig config = ProjectConfig.read(md);
String refsUsersShardedId = RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}";
config.remove(config.getAccessSection(refsUsersShardedId));
GroupReference registered = systemGroupBackend.getGroup(REGISTERED_USERS);
AccessSection users = config.getAccessSection(refsUsersShardedId, true);
grant(config, users, Permission.READ, false, true, registered);
grant(config, users, Permission.PUSH, false, true, registered);
grant(config, users, Permission.SUBMIT, false, true, registered);
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
md.setMessage(COMMIT_MSG);
config.commit(md);
} catch (ConfigInvalidException | IOException ex) {
throw new OrmException(ex);
}
}
use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.
the class Schema_128 method migrateData.
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
try (Repository git = repoManager.openRepository(allProjectsName);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allProjectsName, git)) {
ProjectConfig config = ProjectConfig.read(md);
GroupReference registered = systemGroupBackend.getGroup(REGISTERED_USERS);
AccessSection refsFor = config.getAccessSection("refs/for/*", true);
grant(config, refsFor, Permission.ADD_PATCH_SET, false, false, registered);
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
md.setMessage(COMMIT_MSG);
config.commit(md);
} catch (ConfigInvalidException | IOException ex) {
throw new OrmException(ex);
}
}
use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.
the class CreateProject method createProjectConfig.
private void createProjectConfig(CreateProjectArgs args) throws IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.create(args.getProject())) {
ProjectConfig config = ProjectConfig.read(md);
Project newProject = config.getProject();
newProject.setDescription(args.projectDescription);
newProject.setSubmitType(MoreObjects.firstNonNull(args.submitType, repositoryCfg.getDefaultSubmitType(args.getProject())));
newProject.setUseContributorAgreements(args.contributorAgreements);
newProject.setUseSignedOffBy(args.signedOffBy);
newProject.setUseContentMerge(args.contentMerge);
newProject.setCreateNewChangeForAllNotInTarget(args.newChangeForAllNotInTarget);
newProject.setRequireChangeID(args.changeIdRequired);
newProject.setMaxObjectSizeLimit(args.maxObjectSizeLimit);
if (args.newParent != null) {
newProject.setParentName(args.newParent.getProject().getNameKey());
}
if (!args.ownerIds.isEmpty()) {
AccessSection all = config.getAccessSection(AccessSection.ALL, true);
for (AccountGroup.UUID ownerId : args.ownerIds) {
GroupDescription.Basic g = groupBackend.get(ownerId);
if (g != null) {
GroupReference group = config.resolve(GroupReference.forGroup(g));
all.getPermission(Permission.OWNER, true).add(new PermissionRule(group));
}
}
}
md.setMessage("Created project\n");
config.commit(md);
md.getRepository().setGitwebDescription(args.projectDescription);
}
projectCache.onCreateProject(args.getProject());
}
use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.
the class GroupQueryBuilder method owner.
@Operator
public Predicate<AccountGroup> owner(String owner) throws QueryParseException {
AccountGroup group = args.groupCache.get(new AccountGroup.UUID(owner));
if (group != null) {
return GroupPredicates.owner(group.getGroupUUID());
}
GroupReference g = GroupBackends.findBestSuggestion(args.groupBackend, owner);
if (g == null) {
throw error("Group " + owner + " not found");
}
return GroupPredicates.owner(g.getUUID());
}
Aggregations