use of com.google.gerrit.extensions.common.GroupOptionsInfo in project gerrit by GerritCodeReview.
the class GroupsIT method groupOptions.
@Test
public void groupOptions() throws Exception {
String name = name("group");
gApi.groups().create(name);
// get options
assertThat(gApi.groups().id(name).options().visibleToAll).isNull();
// set options
GroupOptionsInfo options = new GroupOptionsInfo();
options.visibleToAll = true;
gApi.groups().id(name).options(options);
assertThat(gApi.groups().id(name).options().visibleToAll).isTrue();
}
use of com.google.gerrit.extensions.common.GroupOptionsInfo in project gerrit by GerritCodeReview.
the class GroupJson method createOptions.
public static GroupOptionsInfo createOptions(GroupDescription.Basic group) {
GroupOptionsInfo options = new GroupOptionsInfo();
AccountGroup ag = GroupDescriptions.toAccountGroup(group);
if (ag != null && ag.isVisibleToAll()) {
options.visibleToAll = true;
}
return options;
}
use of com.google.gerrit.extensions.common.GroupOptionsInfo in project gerrit by GerritCodeReview.
the class PutOptions method apply.
@Override
public GroupOptionsInfo apply(GroupResource resource, GroupOptionsInfo input) throws MethodNotAllowedException, AuthException, BadRequestException, ResourceNotFoundException, OrmException, IOException {
if (resource.toAccountGroup() == null) {
throw new MethodNotAllowedException();
} else if (!resource.getControl().isOwner()) {
throw new AuthException("Not group owner");
}
if (input == null) {
throw new BadRequestException("options are required");
}
if (input.visibleToAll == null) {
input.visibleToAll = false;
}
AccountGroup group = db.get().accountGroups().get(resource.toAccountGroup().getId());
if (group == null) {
throw new ResourceNotFoundException();
}
group.setVisibleToAll(input.visibleToAll);
db.get().accountGroups().update(Collections.singleton(group));
groupCache.evict(group);
GroupOptionsInfo options = new GroupOptionsInfo();
if (group.isVisibleToAll()) {
options.visibleToAll = true;
}
return options;
}
Aggregations