public void processNextBulletin() { if (isSleeping()) return; BulletinMirroringInformation item = getNextItemToRetrieve(); if (item == null) { scheduleSleep(); return; } // TODO handle delete requests when we are propagating deletes. try { UniversalId uid = item.getUid(); String publicCode = MartusCrypto.getFormattedPublicCode(uid.getAccountId()); logNotice("Getting bulletin: " + publicCode + "->" + uid.getLocalId()); String bur = retrieveBurFromMirror(uid); File zip = File.createTempFile("$$$MirroringRetriever", null); try { zip.deleteOnExit(); retrieveOneBulletin(zip, uid); long zipSize = zip.length(); long mTime = item.getmTime(); BulletinHeaderPacket bhp = store.saveZipFileToDatabase(zip, uid.getAccountId(), mTime); store.writeBur(bhp, bur); store.deleteDel(bhp.getUniversalId()); logNotice( "Stored bulletin: " + publicCode + "->" + uid.getLocalId() + " Size: " + zipSize); } finally { zip.delete(); } } catch (ServerErrorException e) { logError("Supplier server:", e); } catch (ServerNotAvailableException e) { // TODO: Notify once per hour that something is wrong } catch (Exception e) { logError(e); } }