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);
}
});
}
}
Aggregations