Search in sources :

Example 41 with GroupReference

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());
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) GroupDescription(com.google.gerrit.common.data.GroupDescription) Project(com.google.gerrit.reviewdb.client.Project) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) PermissionRule(com.google.gerrit.common.data.PermissionRule) GroupReference(com.google.gerrit.common.data.GroupReference) AccessSection(com.google.gerrit.common.data.AccessSection) MetaDataUpdate(com.google.gerrit.server.git.MetaDataUpdate)

Aggregations

GroupReference (com.google.gerrit.common.data.GroupReference)41 PermissionRule (com.google.gerrit.common.data.PermissionRule)11 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)9 AccessSection (com.google.gerrit.common.data.AccessSection)6 Permission (com.google.gerrit.common.data.Permission)6 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)6 IOException (java.io.IOException)6 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)5 OrmException (com.google.gwtorm.server.OrmException)5 Test (org.junit.Test)5 GroupDescription (com.google.gerrit.common.data.GroupDescription)4 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)4 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)4 NoSuchGroupException (com.google.gerrit.common.errors.NoSuchGroupException)3 Project (com.google.gerrit.reviewdb.client.Project)3 PluginConfig (com.google.gerrit.server.config.PluginConfig)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Config (org.eclipse.jgit.lib.Config)3 Repository (org.eclipse.jgit.lib.Repository)3