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; }
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; }