/** * Attempts to download results for the specified <code>ScanSession</code>. * * @param session the <code>ScanSession</code> for which results should be downloaded * @return an updated <code>ScanSession</code> with the newly updated results */ private static ScanSession download(ScanSession session) { ScanResult scanResult = MetascanOnlineInterface.downloadResults(session); if (scanResult != null) { session.setScanResult(scanResult); return session; } return null; }
/** * Attempts to loop through and download results for the <code>ScanSession</code>s that are * currently present in the <code>ScanManager</code>. * * <p>If a session is found to be complete, it will be sent back to the <code>ScanManager</code> * for finalization. If a session is not complete, it will be recycled back to have results * re-downloaded. */ private static void downloadResults() { ArrayList<ScanSession> incompleteSessions = new ArrayList(); ScanSession session; while ((session = ScanManager.getNextSessionForDownload()) != null) { ScanSession updatedSession = download(session); if (updatedSession != null) { if (updatedSession.isComplete()) ScanManager.finalizeSession(session); else incompleteSessions.add(session); } else { incompleteSessions.add(session); } } for (ScanSession incompleteSession : incompleteSessions) ScanManager.pushSessionForDownload(incompleteSession); }