use of org.sonarqube.ws.WsPermissions.WsSearchGlobalPermissionsResponse in project sonarqube by SonarSource.
the class SearchGlobalPermissionsAction method buildResponse.
private WsSearchGlobalPermissionsResponse buildResponse(DbSession dbSession, OrganizationDto org) {
WsSearchGlobalPermissionsResponse.Builder response = WsSearchGlobalPermissionsResponse.newBuilder();
Permission.Builder permission = newBuilder();
OrganizationPermission.all().map(OrganizationPermission::getKey).forEach(permissionKey -> {
PermissionQuery query = permissionQuery(permissionKey);
response.addPermissions(permission.clear().setKey(permissionKey).setName(i18nName(permissionKey)).setDescription(i18nDescriptionMessage(permissionKey)).setUsersCount(countUsers(dbSession, org, query)).setGroupsCount(countGroups(dbSession, org, permissionKey)));
});
return response.build();
}
use of org.sonarqube.ws.WsPermissions.WsSearchGlobalPermissionsResponse in project sonarqube by SonarSource.
the class SearchGlobalPermissionsAction method handle.
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto org = support.findOrganization(dbSession, wsRequest.param(PARAM_ORGANIZATION));
checkGlobalAdmin(userSession, org.getUuid());
WsSearchGlobalPermissionsResponse response = buildResponse(dbSession, org);
writeProtobuf(response, wsRequest, wsResponse);
}
}
Aggregations