public void doAjax ( StaplerRequest req , StaplerResponse rsp , @ Header ( "n" ) String n ) throws IOException , ServletException { rsp . setContentType ( "text/html;charset=UTF-8" ) ; // pick up builds to send back List < T > items = new ArrayList <> ( ) ; if ( n != null ) { String nn = null ; // we'll compute next n here // list up all builds >=n. for ( T t : baseList ) { if ( adapter . compare ( t , n ) >= 0 ) { items . add ( t ) ; if ( adapter . isBuilding ( t ) ) nn = adapter . getKey ( t ) ; // the next fetch should start from youngest build in progress } else break ; } if ( nn == null ) { if ( items . isEmpty ( ) ) { // nothing to report back. next fetch should retry the same 'n' nn = n ; } else { // every record fetched this time is frozen. next fetch should start from the next build nn = adapter . getNextKey ( adapter . getKey ( items . get ( 0 ) ) ) ; } } baseList = items ; rsp . setHeader ( "n" , nn ) ; firstTransientBuildKey = nn ; // all builds >= nn should be marked transient } HistoryPageFilter page = getHistoryPageFilter ( ) ; req . getView ( page , "ajaxBuildHistory.jelly" ) . forward ( req , rsp ) ; }
Handles AJAX requests from browsers to update build history .