Search in sources :

Example 1 with SearchResponse

use of org.sonarqube.ws.Rules.SearchResponse in project sonarqube by SonarSource.

the class SearchAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    try (DbSession dbSession = dbClient.openSession(false)) {
        SearchWsRequest searchWsRequest = toSearchWsRequest(request);
        SearchOptions context = buildSearchOptions(searchWsRequest);
        RuleQuery query = ruleQueryFactory.createRuleQuery(request);
        SearchResult searchResult = doSearch(dbSession, query, context);
        SearchResponse responseBuilder = buildResponse(dbSession, searchWsRequest, context, searchResult, query);
        writeProtobuf(responseBuilder, request, response);
    }
}
Also used : DbSession(org.sonar.db.DbSession) SearchWsRequest(org.sonarqube.ws.client.rule.SearchWsRequest) RuleQuery(org.sonar.server.rule.index.RuleQuery) SearchOptions(org.sonar.server.es.SearchOptions) SearchResponse(org.sonarqube.ws.Rules.SearchResponse)

Example 2 with SearchResponse

use of org.sonarqube.ws.Rules.SearchResponse in project sonarqube by SonarSource.

the class DefaultActiveRulesLoader method load.

@Override
public List<LoadedActiveRule> load(String qualityProfileKey) {
    List<LoadedActiveRule> ruleList = new LinkedList<>();
    int page = 1;
    int pageSize = 500;
    int loaded = 0;
    while (true) {
        GetRequest getRequest = new GetRequest(getUrl(qualityProfileKey, page, pageSize));
        SearchResponse response = loadFromStream(wsClient.call(getRequest).contentStream());
        List<LoadedActiveRule> pageRules = readPage(response);
        ruleList.addAll(pageRules);
        loaded += response.getPs();
        if (response.getTotal() <= loaded) {
            break;
        }
        page++;
    }
    return ruleList;
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) LinkedList(java.util.LinkedList) SearchResponse(org.sonarqube.ws.Rules.SearchResponse)

Aggregations

SearchResponse (org.sonarqube.ws.Rules.SearchResponse)2 LinkedList (java.util.LinkedList)1 DbSession (org.sonar.db.DbSession)1 SearchOptions (org.sonar.server.es.SearchOptions)1 RuleQuery (org.sonar.server.rule.index.RuleQuery)1 GetRequest (org.sonarqube.ws.client.GetRequest)1 SearchWsRequest (org.sonarqube.ws.client.rule.SearchWsRequest)1