use of com.google.gerrit.server.group.GroupResource in project gerrit by GerritCodeReview.
the class SetMembersCommand method reportGroupsAction.
private void reportGroupsAction(String action, GroupResource group, List<AccountGroup.UUID> groupUuidList) throws UnsupportedEncodingException, IOException {
String names = groupUuidList.stream().map(uuid -> groupCache.get(uuid).getName()).collect(joining(", "));
out.write(String.format("Groups %s group %s: %s\n", action, group.getName(), names).getBytes(ENC));
}
use of com.google.gerrit.server.group.GroupResource in project gerrit by GerritCodeReview.
the class SetMembersCommand method reportMembersAction.
private void reportMembersAction(String action, GroupResource group, List<Account.Id> accountIdList) throws UnsupportedEncodingException, IOException {
String names = accountIdList.stream().map(accountId -> MoreObjects.firstNonNull(accountCache.get(accountId).getAccount().getPreferredEmail(), "n/a")).collect(joining(", "));
out.write(String.format("Members %s group %s: %s\n", action, group.getName(), names).getBytes(ENC));
}
use of com.google.gerrit.server.group.GroupResource in project gerrit by GerritCodeReview.
the class RenameGroupCommand method run.
@Override
protected void run() throws Failure {
try {
GroupResource rsrc = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(groupName));
PutName.Input input = new PutName.Input();
input.name = newGroupName;
putName.apply(rsrc, input);
} catch (RestApiException | OrmException | IOException | NoSuchGroupException e) {
throw die(e);
}
}
use of com.google.gerrit.server.group.GroupResource in project gerrit by GerritCodeReview.
the class AgreementJson method format.
public AgreementInfo format(ContributorAgreement ca) {
AgreementInfo info = new AgreementInfo();
info.name = ca.getName();
info.description = ca.getDescription();
info.url = ca.getAgreementUrl();
GroupReference autoVerifyGroup = ca.getAutoVerify();
if (autoVerifyGroup != null && self.get().isIdentifiedUser()) {
IdentifiedUser user = identifiedUserFactory.create(self.get().getAccountId());
try {
GroupControl gc = genericGroupControlFactory.controlFor(user, autoVerifyGroup.getUUID());
GroupResource group = new GroupResource(gc);
info.autoVerifyGroup = groupJson.format(group);
} catch (NoSuchGroupException | OrmException e) {
log.warn("autoverify group \"" + autoVerifyGroup.getName() + "\" does not exist, referenced in CLA \"" + ca.getName() + "\"");
}
}
return info;
}
use of com.google.gerrit.server.group.GroupResource in project gerrit by GerritCodeReview.
the class SetMembersCommand method run.
@Override
protected void run() throws UnloggedFailure, Failure, Exception {
try {
for (AccountGroup.UUID groupUuid : groups) {
GroupResource resource = groupsCollection.parse(TopLevelResource.INSTANCE, IdString.fromUrl(groupUuid.get()));
if (!accountsToRemove.isEmpty()) {
deleteMembers.apply(resource, fromMembers(accountsToRemove));
reportMembersAction("removed from", resource, accountsToRemove);
}
if (!groupsToRemove.isEmpty()) {
deleteIncludedGroups.apply(resource, fromGroups(groupsToRemove));
reportGroupsAction("excluded from", resource, groupsToRemove);
}
if (!accountsToAdd.isEmpty()) {
addMembers.apply(resource, fromMembers(accountsToAdd));
reportMembersAction("added to", resource, accountsToAdd);
}
if (!groupsToInclude.isEmpty()) {
addIncludedGroups.apply(resource, fromGroups(groupsToInclude));
reportGroupsAction("included to", resource, groupsToInclude);
}
}
} catch (RestApiException e) {
throw die(e.getMessage());
}
}
Aggregations