Search in sources :

Example 1 with GroupReference

use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.

the class ReviewersUtil method suggestAccountGroups.

private List<SuggestedReviewerInfo> suggestAccountGroups(SuggestReviewers suggestReviewers, ProjectControl projectControl, VisibilityControl visibilityControl, int limit) throws OrmException, IOException {
    try (Timer0.Context ctx = metrics.queryGroupsLatency.start()) {
        List<SuggestedReviewerInfo> groups = new ArrayList<>();
        for (GroupReference g : suggestAccountGroups(suggestReviewers, projectControl)) {
            GroupAsReviewer result = suggestGroupAsReviewer(suggestReviewers, projectControl.getProject(), g, visibilityControl);
            if (result.allowed || result.allowedWithConfirmation) {
                GroupBaseInfo info = new GroupBaseInfo();
                info.id = Url.encode(g.getUUID().get());
                info.name = g.getName();
                SuggestedReviewerInfo suggestedReviewerInfo = new SuggestedReviewerInfo();
                suggestedReviewerInfo.group = info;
                suggestedReviewerInfo.count = result.size;
                if (result.allowedWithConfirmation) {
                    suggestedReviewerInfo.confirm = true;
                }
                groups.add(suggestedReviewerInfo);
                if (groups.size() >= limit) {
                    break;
                }
            }
        }
        return groups;
    }
}
Also used : SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) ArrayList(java.util.ArrayList) GroupBaseInfo(com.google.gerrit.extensions.common.GroupBaseInfo) Timer0(com.google.gerrit.metrics.Timer0) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 2 with GroupReference

use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.

the class AclUtil method grant.

public static void grant(ProjectConfig config, AccessSection section, LabelType type, int min, int max, GroupReference... groupList) {
    String name = Permission.LABEL + type.getName();
    Permission p = section.getPermission(name, true);
    for (GroupReference group : groupList) {
        if (group != null) {
            PermissionRule r = rule(config, group);
            r.setRange(min, max);
            p.add(r);
        }
    }
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) Permission(com.google.gerrit.common.data.Permission) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 3 with GroupReference

use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.

the class AclUtil method grant.

public static void grant(ProjectConfig config, AccessSection section, String permission, boolean force, Boolean exclusive, GroupReference... groupList) {
    Permission p = section.getPermission(permission, true);
    if (exclusive != null) {
        p.setExclusiveGroup(exclusive);
    }
    for (GroupReference group : groupList) {
        if (group != null) {
            PermissionRule r = rule(config, group);
            r.setForce(force);
            p.add(r);
        }
    }
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) Permission(com.google.gerrit.common.data.Permission) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 4 with GroupReference

use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.

the class AclUtil method block.

public static void block(ProjectConfig config, AccessSection section, String permission, GroupReference... groupList) {
    Permission p = section.getPermission(permission, true);
    for (GroupReference group : groupList) {
        if (group != null) {
            PermissionRule r = rule(config, group);
            r.setBlock();
            p.add(r);
        }
    }
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) Permission(com.google.gerrit.common.data.Permission) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 5 with GroupReference

use of com.google.gerrit.common.data.GroupReference in project gerrit by GerritCodeReview.

the class Util method newRule.

public static PermissionRule newRule(ProjectConfig project, AccountGroup.UUID groupUUID) {
    GroupReference group = new GroupReference(groupUUID, groupUUID.get());
    group = project.resolve(group);
    return new PermissionRule(group);
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) GroupReference(com.google.gerrit.common.data.GroupReference)

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