public boolean doWeWantThis(BulletinMirroringInformation mirroringInfo) {
    // TODO handle delete requests when we are propagating deletes,
    DatabaseKey key = getDatabaseKey(mirroringInfo);
    if (store.isHidden(key)) return false;

    UniversalId uid = mirroringInfo.getUid();
    DatabaseKey sealedKey = DatabaseKey.createSealedKey(uid);
    if (store.doesBulletinRevisionExist(sealedKey)) return false;

    try {
      if (mirroringInfo.isSealed()) return (!store.doesBulletinRevisionExist(key));

      if (store.doesBulletinDelRecordExist(DeleteRequestRecord.getDelKey(uid))) {
        DeleteRequestRecord delRecord =
            new DeleteRequestRecord(store.getDatabase(), uid, store.getSignatureVerifier());
        if (delRecord.isBefore(mirroringInfo.mTime)) return true;
        return false;
      }

      if (!store.doesBulletinRevisionExist(key)) return true;

      long currentBulletinsmTime = store.getDatabase().getmTime(key);
      if (mirroringInfo.getmTime() > currentBulletinsmTime) return true;
      return false;
    } catch (Exception e) {
      logError(e.getMessage(), e);
    }
    return false;
  }
 private int verifyStatus(
     int bulletinsVerified,
     BulletinMirroringInformation returnedInfo,
     BulletinHeaderPacket bhp,
     String tag) {
   if (returnedInfo.getUid().equals(bhp.getUniversalId())) {
     assertEquals(
         "Status for " + tag + " not correct?", bhp.getStatus(), returnedInfo.getStatus());
     ++bulletinsVerified;
   }
   return bulletinsVerified;
 }
  protected Vector listOnlyPacketsThatWeWantUsingLocalIds(
      String accountId, Vector listWithLocalIds) {
    Vector mirroringInfo = new Vector();
    for (int i = 0; i < listWithLocalIds.size(); ++i) {
      UniversalId uid =
          UniversalId.createFromAccountAndLocalId(
              accountId, (String) ((Vector) listWithLocalIds.get(i)).get(0));
      BulletinMirroringInformation mirroringData = new BulletinMirroringInformation(uid);
      mirroringInfo.add(mirroringData.getInfoWithLocalId());
    }

    return listOnlyPacketsThatWeWantUsingBulletinMirroringInformation(accountId, mirroringInfo);
  }
  Vector writeSampleAvailableIDPacket(BulletinHeaderPacket bhp) throws Exception {

    StringWriter writer = new StringWriter();
    byte[] sigBytes = bhp.writeXml(writer, authorSecurity);
    DatabaseKey key = null;
    if (bhp.getStatus().equals(BulletinConstants.STATUSDRAFT))
      key = DatabaseKey.createDraftKey(bhp.getUniversalId());
    else key = DatabaseKey.createSealedKey(bhp.getUniversalId());

    String sigString = StreamableBase64.encode(sigBytes);
    MockDatabase db = new MockServerDatabase();
    db.writeRecord(key, "Some text");
    supplier.addAvailableIdsToMirror(db, key, sigString);

    BulletinMirroringInformation bulletinInfo =
        new BulletinMirroringInformation(db, key, sigString);
    Vector info = bulletinInfo.getInfoWithLocalId();
    return info;
  }
  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);
    }
  }
 private DatabaseKey getDatabaseKey(BulletinMirroringInformation mirroringInfo) {
   DatabaseKey key = null;
   if (mirroringInfo.isSealed()) key = DatabaseKey.createSealedKey(mirroringInfo.getUid());
   else if (mirroringInfo.isDraft()) key = DatabaseKey.createDraftKey(mirroringInfo.getUid());
   return key;
 }