public List < CommitStatus > getCommitStatuses ( String statusUrl , GitHubRepo repo ) throws RestClientException { Map < String , CommitStatus > statuses = new HashMap <> ( ) ; // decrypt password String decryptedPassword = decryptString ( repo . getPassword ( ) , settings . getKey ( ) ) ; String personalAccessToken = ( String ) repo . getOptions ( ) . get ( "personalAccessToken" ) ; String decryptedPersonalAccessToken = decryptString ( personalAccessToken , settings . getKey ( ) ) ; boolean lastPage = false ; String queryUrlPage = statusUrl ; while ( ! lastPage ) { ResponseEntity < String > response = makeRestCall ( queryUrlPage , repo . getUserId ( ) , decryptedPassword , decryptedPersonalAccessToken ) ; JSONArray jsonArray = parseAsArray ( response ) ; for ( Object item : jsonArray ) { JSONObject jsonObject = ( JSONObject ) item ; String context = str ( jsonObject , "context" ) ; if ( ( context != null ) && ! statuses . containsKey ( context ) ) { CommitStatus status = new CommitStatus ( ) ; status . setContext ( context ) ; status . setDescription ( str ( jsonObject , "description" ) ) ; status . setState ( str ( jsonObject , "state" ) ) ; statuses . put ( context , status ) ; } } if ( CollectionUtils . isEmpty ( jsonArray ) ) { lastPage = true ; } else { if ( isThisLastPage ( response ) ) { lastPage = true ; } else { lastPage = false ; queryUrlPage = getNextPageUrl ( response ) ; } } } return new ArrayList <> ( statuses . values ( ) ) ; }
Get commit statuses from the given commit status url Retrieve the most recent status for each unique context .