Search in sources :

Example 1 with GroupMap

use of com.google.gerrit.client.groups.GroupMap in project gerrit by GerritCodeReview.

the class PermissionEditor method addGroup.

private void addGroup(final GroupReference ref) {
    if (ref.getUUID() != null) {
        if (value.getRule(ref) == null) {
            PermissionRule newRule = value.getRule(ref, true);
            if (validRange != null) {
                int min = validRange.getDefaultMin();
                int max = validRange.getDefaultMax();
                newRule.setRange(min, max);
            } else if (GlobalCapability.PRIORITY.equals(value.getName())) {
                newRule.setAction(PermissionRule.Action.BATCH);
            }
            rules.getList().add(newRule);
        }
        groupToAdd.setValue(null);
        groupToAdd.setFocus(true);
    } else {
        // If the oracle didn't get to complete a UUID, resolve it now.
        //
        addRule.setEnabled(false);
        GroupMap.suggestAccountGroupForProject(projectName.get(), ref.getName(), 1, new GerritCallback<GroupMap>() {

            @Override
            public void onSuccess(GroupMap result) {
                addRule.setEnabled(true);
                if (result.values().length() == 1) {
                    addGroup(new GroupReference(result.values().get(0).getGroupUUID(), result.values().get(0).name()));
                } else {
                    groupToAdd.setFocus(true);
                    new ErrorDialog(Gerrit.M.noSuchGroupMessage(ref.getName())).center();
                }
            }

            @Override
            public void onFailure(Throwable caught) {
                addRule.setEnabled(true);
                super.onFailure(caught);
            }
        });
    }
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) GroupMap(com.google.gerrit.client.groups.GroupMap) ErrorDialog(com.google.gerrit.client.ErrorDialog) GroupReference(com.google.gerrit.common.data.GroupReference)

Aggregations

ErrorDialog (com.google.gerrit.client.ErrorDialog)1 GroupMap (com.google.gerrit.client.groups.GroupMap)1 GroupReference (com.google.gerrit.common.data.GroupReference)1 PermissionRule (com.google.gerrit.common.data.PermissionRule)1