use of com.google.gerrit.common.data.PermissionRule 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());
}
Aggregations