/** * The fetch servlet also exposes document snapshots through a longer url * (/fetch/domain/waveid/domain/waveletid/docid). * * @throws Exception */ public void testGetDocument() throws Exception { WaveletData wavelet = waveletProvider.getHostedWavelet(); for (String docId : wavelet.getDocumentIds()) { // We currently have no way to deserialize a document. Instead, we'll // serialize the expected document and compare with what we get from the // fetch servlet. StringWriter writer = new StringWriter(); BlipData expectedDoc = wavelet.getDocument(docId); writer.append("" + protoSerializer.toJson(SnapshotSerializer.serializeDocument(expectedDoc))); String expectedResult = writer.toString(); WaveRef waveref = WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId(), docId); String actualResult = fetchWaveRef(waveref); assertEquals(expectedResult, actualResult); } }
/** * The fetch servlet also exposes document snapshots through a longer url * (/fetch/domain/waveid/domain/waveletid/docid). * * @throws Exception */ public void testGetDocument() throws Exception { WaveletData wavelet = waveletProvider.getHostedWavelet(); for (String docId : wavelet.getDocumentIds()) { // We currently have no way to deserialize a document. Instead, we'll // serialize the expected document and compare with what we get from the // fetch servlet. StringWriter writer = new StringWriter(); BlipData expectedDoc = wavelet.getDocument(docId); writer.append("" + protoSerializer.toJson(SnapshotSerializer.serializeDocument(expectedDoc))); String expectedResult = writer.toString(); WaveRef waveref = WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId(), docId); String actualResult = fetchWaveRef(waveref); assertEquals(expectedResult, actualResult); } }
for (String docId : snapshot.getDocumentIds()) { if (docId.equals(waveref.getDocumentId())) { docSnapshot = SnapshotSerializer.serializeDocument(snapshot.getDocument(docId)); break;
/** * Serializes a snapshot for a wavelet. * * @param wavelet wavelet to snapshot * @param hashedVersion hashed version of the wavelet * @return a wavelet snapshot that contains all the information in the * original wavelet. */ public static WaveletSnapshot serializeWavelet(ReadableWaveletData wavelet, HashedVersion hashedVersion) { WaveletSnapshot.Builder builder = WaveletSnapshot.newBuilder(); builder.setWaveletId(ModernIdSerialiser.INSTANCE.serialiseWaveletId(wavelet.getWaveletId())); for (ParticipantId participant : wavelet.getParticipants()) { builder.addParticipantId(participant.toString()); } for (String id : wavelet.getDocumentIds()) { ReadableBlipData data = wavelet.getDocument(id); builder.addDocument(serializeDocument(data)); } builder.setVersion(CoreWaveletOperationSerializer.serialize(hashedVersion)); builder.setLastModifiedTime(wavelet.getLastModifiedTime()); builder.setCreator(wavelet.getCreator().getAddress()); builder.setCreationTime(wavelet.getCreationTime()); return builder.build(); }