use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class AbstractQueryGroupsTest method format.
protected String format(Iterable<GroupInfo> groups) {
StringBuilder b = new StringBuilder();
b.append("[");
Iterator<GroupInfo> it = groups.iterator();
while (it.hasNext()) {
GroupInfo g = it.next();
b.append("{").append(g.id).append(", ").append("name=").append(g.name).append(", ").append("groupId=").append(g.groupId).append(", ").append("url=").append(g.url).append(", ").append("ownerId=").append(g.ownerId).append(", ").append("owner=").append(g.owner).append(", ").append("description=").append(g.description).append(", ").append("visibleToAll=").append(toBoolean(g.options.visibleToAll)).append("}");
if (it.hasNext()) {
b.append(", ");
}
}
b.append("]");
return b.toString();
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class AbstractQueryGroupsTest method rawDocument.
@Test
public void rawDocument() throws Exception {
GroupInfo group1 = createGroup(name("group1"));
AccountGroup.UUID uuid = AccountGroup.uuid(group1.id);
Optional<FieldBundle> rawFields = indexes.getSearchIndex().getRaw(uuid, QueryOptions.create(IndexConfig.createDefault(), 0, 10, indexes.getSearchIndex().getSchema().getStoredFields().keySet()));
assertThat(rawFields).isPresent();
assertThat(rawFields.get().getValue(GroupField.UUID)).isEqualTo(uuid.get());
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class AbstractQueryGroupsTest method byDefaultField.
@Test
public void byDefaultField() throws Exception {
GroupInfo group1 = createGroup(name("foo-group"));
GroupInfo group2 = createGroup(name("group2"));
GroupInfo group3 = createGroupWithDescription(name("group3"), "decription that contains foo and the UUID of group2: " + group2.id);
assertQuery("non-existing");
assertQuery("foo", group1, group3);
assertQuery(group2.id, group2, group3);
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method group.
private AccountGroup group(String name) throws Exception {
GroupInfo group = createGroupFactory.create(name(name)).apply(TopLevelResource.INSTANCE, null);
GroupDescription.Basic d = groups.parseInternal(Url.decode(group.id));
return GroupDescriptions.toAccountGroup(d);
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class AddIncludedGroups method apply.
@Override
public List<GroupInfo> apply(GroupResource resource, Input input) throws MethodNotAllowedException, AuthException, UnprocessableEntityException, OrmException {
AccountGroup group = resource.toAccountGroup();
if (group == null) {
throw new MethodNotAllowedException();
}
input = Input.init(input);
GroupControl control = resource.getControl();
Map<AccountGroup.UUID, AccountGroupById> newIncludedGroups = new HashMap<>();
List<GroupInfo> result = new ArrayList<>();
Account.Id me = control.getUser().getAccountId();
for (String includedGroup : input.groups) {
GroupDescription.Basic d = groupsCollection.parse(includedGroup);
if (!control.canAddGroup()) {
throw new AuthException(String.format("Cannot add group: %s", d.getName()));
}
if (!newIncludedGroups.containsKey(d.getGroupUUID())) {
AccountGroupById.Key agiKey = new AccountGroupById.Key(group.getId(), d.getGroupUUID());
AccountGroupById agi = db.get().accountGroupById().get(agiKey);
if (agi == null) {
agi = new AccountGroupById(agiKey);
newIncludedGroups.put(d.getGroupUUID(), agi);
}
}
result.add(json.format(d));
}
if (!newIncludedGroups.isEmpty()) {
auditService.dispatchAddGroupsToGroup(me, newIncludedGroups.values());
db.get().accountGroupById().insert(newIncludedGroups.values());
for (AccountGroupById agi : newIncludedGroups.values()) {
groupIncludeCache.evictParentGroupsOf(agi.getIncludeUUID());
}
groupIncludeCache.evictSubgroupsOf(group.getGroupUUID());
}
return result;
}
Aggregations