Search in sources :

Example 1 with Result

use of com.checkmarx.flow.dto.rally.Result in project cx-flow by checkmarx-ltd.

the class RallyIssueTracker method getIssues.

/**
 * Get all issues for a Rally repository
 *
 * @return List of Rally Issues
 * @ full name (owner/repo format)
 */
@Override
public List<Issue> getIssues(ScanRequest request) {
    log.info("Executing getIssues Rally API call");
    List<Issue> issues = new ArrayList<>();
    HttpEntity httpEntity = new HttpEntity(createAuthHeaders());
    try {
        int pageIndex = 0;
        QueryResult rallyQuery;
        ResponseEntity<QueryResult> response;
        // 
        // / Read the first list of defects from Rally, it will contain the totalResultCount we can use
        // / to figure out how many more pages of data needs to be pulled.
        // 
        String query = createRallyTagQuery(request);
        response = restTemplate.exchange(properties.getApiUrl().concat(GET_ISSUES), HttpMethod.GET, httpEntity, QueryResult.class, query, pageIndex, ISSUES_PER_PAGE);
        rallyQuery = response.getBody();
        // 
        // / Now decode the CxFlow defects and continue reading lists of defects until we've found the
        // totalResultCount
        // 
        long totalResultCount = getTotalResultCount(rallyQuery);
        int resultsFound = 0;
        while (resultsFound < totalResultCount) {
            resultsFound += rallyQuery.getQueryResult().getPageSize();
            // Create CxFlow issues from Rally issues
            for (Result issue : rallyQuery.getQueryResult().getResults()) {
                Issue i = mapToIssue(issue);
                issues.add(i);
            }
            // If there are more issues on the server, fetch them
            if (resultsFound < rallyQuery.getQueryResult().getTotalResultCount()) {
                pageIndex++;
                response = restTemplate.exchange(properties.getApiUrl().concat(GET_ISSUES), HttpMethod.GET, httpEntity, QueryResult.class, query, pageIndex, ISSUES_PER_PAGE);
                rallyQuery = response.getBody();
            }
        }
        return issues;
    } catch (RestClientException e) {
        return new ArrayList<>();
    }
}
Also used : QueryResult(com.checkmarx.flow.dto.rally.QueryResult) Issue(com.checkmarx.flow.dto.Issue) ArrayList(java.util.ArrayList) RestClientException(org.springframework.web.client.RestClientException) QueryResult(com.checkmarx.flow.dto.rally.QueryResult) Result(com.checkmarx.flow.dto.rally.Result)

Aggregations

Issue (com.checkmarx.flow.dto.Issue)1 QueryResult (com.checkmarx.flow.dto.rally.QueryResult)1 Result (com.checkmarx.flow.dto.rally.Result)1 ArrayList (java.util.ArrayList)1 RestClientException (org.springframework.web.client.RestClientException)1