/** * Deserializes the snapshot contained in the {@link WaveletSnapshot} into an {@link * ObservableWaveletData}. * * @param snapshot the {@link WaveletSnapshot} to deserialize. * @throws OperationException if the ops in the snapshot can not be applied. * @throws InvalidParticipantAddress * @throws InvalidIdException */ public static ObservableWaveletData deserializeWavelet(WaveletSnapshot snapshot, WaveId waveId) throws OperationException, InvalidParticipantAddress, InvalidIdException { ObservableWaveletData.Factory<? extends ObservableWaveletData> factory = WaveletDataImpl.Factory.create( ObservablePluggableMutableDocument.createFactory(SchemaCollection.empty())); ParticipantId author = ParticipantId.of(snapshot.getCreator()); WaveletId waveletId = ModernIdSerialiser.INSTANCE.deserialiseWaveletId(snapshot.getWaveletId()); long creationTime = snapshot.getCreationTime(); ObservableWaveletData wavelet = factory.create( new EmptyWaveletSnapshot( waveId, waveletId, author, CoreWaveletOperationSerializer.deserialize(snapshot.getVersion()), creationTime)); for (String participant : snapshot.getParticipantIdList()) { wavelet.addParticipant(getParticipantId(participant)); } for (DocumentSnapshot document : snapshot.getDocumentList()) { addDocumentSnapshotToWavelet(document, wavelet); } wavelet.setVersion(snapshot.getVersion().getVersion()); wavelet.setLastModifiedTime(snapshot.getLastModifiedTime()); // The creator and creation time are set when the empty wavelet template is // created above. return wavelet; }
/** @return the registry of documents in the wave. Subclasses may override. */ protected WaveDocuments<LazyContentDocument> createDocumentRegistry() { IndexedDocumentImpl.performValidation = false; DocumentFactory<?> dataDocFactory = ObservablePluggableMutableDocument.createFactory(createSchemas()); DocumentFactory<LazyContentDocument> blipDocFactory = new DocumentFactory<LazyContentDocument>() { private final Registries registries = RegistriesHolder.get(); @Override public LazyContentDocument create( WaveletId waveletId, String docId, DocInitialization content) { // TODO(piotrkaleta,hearnden): hook up real diff state. SimpleDiffDoc noDiff = SimpleDiffDoc.create(content, null); return LazyContentDocument.create(registries, noDiff); } }; return WaveDocuments.create(blipDocFactory, dataDocFactory); }