Search in sources :

Example 1 with SearchProjectPermissionsWsResponse

use of org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse in project sonarqube by SonarSource.

the class SearchProjectPermissionsAction method buildResponse.

private SearchProjectPermissionsWsResponse buildResponse(SearchProjectPermissionsData data) {
    SearchProjectPermissionsWsResponse.Builder response = SearchProjectPermissionsWsResponse.newBuilder();
    Permission.Builder permissionResponse = Permission.newBuilder();
    Project.Builder rootComponentBuilder = Project.newBuilder();
    for (ComponentDto rootComponent : data.rootComponents()) {
        rootComponentBuilder.clear().setId(rootComponent.uuid()).setKey(rootComponent.key()).setQualifier(rootComponent.qualifier()).setName(rootComponent.name());
        for (String permission : data.permissions(rootComponent.getId())) {
            rootComponentBuilder.addPermissions(permissionResponse.clear().setKey(permission).setUsersCount(data.userCount(rootComponent.getId(), permission)).setGroupsCount(data.groupCount(rootComponent.getId(), permission)));
        }
        response.addProjects(rootComponentBuilder);
    }
    for (String permissionKey : ProjectPermissions.ALL) {
        response.addPermissions(permissionResponse.clear().setKey(permissionKey).setName(i18nName(permissionKey)).setDescription(i18nDescriptionMessage(permissionKey)));
    }
    Paging paging = data.paging();
    response.setPaging(Common.Paging.newBuilder().setPageIndex(paging.pageIndex()).setPageSize(paging.pageSize()).setTotal(paging.total()));
    return response.build();
}
Also used : Project(org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse.Project) SearchProjectPermissionsWsResponse(org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse) Paging(org.sonar.api.utils.Paging) Permission(org.sonarqube.ws.WsPermissions.Permission) ComponentDto(org.sonar.db.component.ComponentDto)

Example 2 with SearchProjectPermissionsWsResponse

use of org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse in project sonarqube by SonarSource.

the class SearchProjectPermissionsAction method handle.

@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
    SearchProjectPermissionsWsResponse searchProjectPermissionsWsResponse = doHandle(toSearchProjectPermissionsWsRequest(wsRequest));
    writeProtobuf(searchProjectPermissionsWsResponse, wsRequest, wsResponse);
}
Also used : SearchProjectPermissionsWsResponse(org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse)

Aggregations

SearchProjectPermissionsWsResponse (org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse)2 Paging (org.sonar.api.utils.Paging)1 ComponentDto (org.sonar.db.component.ComponentDto)1 Permission (org.sonarqube.ws.WsPermissions.Permission)1 Project (org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse.Project)1