Package org.waveprotocol.wave.model.wave.data.impl

Examples of org.waveprotocol.wave.model.wave.data.impl.WaveletDataImpl


  private WaveletEntry parseConvWaveletData(
      @Nullable ConnectResponse connectResponse, WaveletDiffSnapshot diffSnapshot,
      DocumentFactory<?> docFactory, StringMap<DocOp> diffMap) {
    WaveSerializer waveSerializer = new WaveSerializer(new ClientMessageSerializer(), docFactory);
    WaveletDataImpl wavelet;
    try {
      StringMap<DocOp> diffOps = waveSerializer.deserializeDocumentsDiffs(diffSnapshot);
      diffMap.putAll(diffOps);
      wavelet = waveSerializer.createWaveletData(
          IdHack.convWaveletNameFromConvObjectId(convObjectId), diffSnapshot);
View Full Code Here


  private WaveletEntry parseUdwData(
      @Nullable ConnectResponse connectResponse, WalkaroundWaveletSnapshot snapshot,
      DocumentFactory<?> docFactory) {
    WaveSerializer serializer = new WaveSerializer(new ClientMessageSerializer(), docFactory);
    WaveletDataImpl wavelet;
    try {
      wavelet = serializer.createWaveletData(
          IdHack.udwWaveletNameFromConvObjectIdAndUdwObjectId(convObjectId, udwObjectId),
          snapshot);
    } catch (MessageException e) {
View Full Code Here

  private WaveViewDataImpl createWaveViewData() {
    final WaveViewDataImpl waveData = WaveViewDataImpl.create(
        IdHack.waveIdFromConvObjectId(convObjectId));
    wavelets.each(new WaveletMap.Proc() {
      @Override public void wavelet(WaveletEntry data) {
        WaveletDataImpl wavelet = data.getWaveletState();
        waveData.addWavelet(wavelet);
      }
    });
    return waveData;
  }
View Full Code Here

      long lastModifiedTime = (long) waveletMessage.getLastModifiedTime();

      HashedVersion hashedVersion = HashedVersion.unsigned(0);
      long version = (long) waveletMessage.getVersion();

      WaveletDataImpl wavelet =
          new WaveletDataImpl(waveletName.waveletId, creator, creationTime, version, hashedVersion,
              lastModifiedTime, waveletName.waveId, docFactory);

      addParticipants(wavelet, waveletMessage.getParticipant());
      addDocuments(wavelet, waveletMessage.getDocument());
View Full Code Here

      long lastModifiedTime = (long) waveletMessage.getLastModifiedTime();

      HashedVersion hashedVersion = HashedVersion.unsigned(0);
      long version = (long) waveletMessage.getVersion();

      WaveletDataImpl wavelet =
          new WaveletDataImpl(waveletName.waveletId, creator, creationTime, version, hashedVersion,
              lastModifiedTime, waveletName.waveId, docFactory);

      addParticipants(wavelet, waveletMessage.getParticipant());
      addDiffDocuments(wavelet, waveletMessage.getDocument());
View Full Code Here

  public LoadedWave loadStaticAtVersion(SlobId convObjectId, @Nullable Long version)
      throws IOException, AccessDeniedException, SlobNotFoundException {
    Preconditions.checkNotNull(convObjectId, "Null convObjectId");
    String rawConvSnapshot = convStore.loadAtVersion(convObjectId, version);
    WaveletName convWaveletName = IdHack.convWaveletNameFromConvObjectId(convObjectId);
    WaveletDataImpl convWavelet = deserializeWavelet(convWaveletName, rawConvSnapshot);
    // TODO(ohler): Determine if it's better UX if we load the UDW here as well.
    return waveWithoutUdw(convObjectId, null, convWavelet);
  }
View Full Code Here

    log(convObjectId, convResult);

    WaveletName convWaveletName = IdHack.convWaveletNameFromConvObjectId(convObjectId);

    // The most recent version of wavelet to get list of documents from.
    WaveletDataImpl convWavelet = deserializeWavelet(convWaveletName, rawConvSnapshot);

    long convVersion = convResult.getVersion();
    Assert.check(convVersion == convWavelet.getVersion(),
        "ConnectResult revision %s does not match wavelet version %s",
        convVersion, convWavelet.getVersion());

    if (!enableUdw) {
      return waveWithoutUdw(convObjectId, convResult, convWavelet);
    } else {
      // Now we go and load some of the history in order to render diffs.
      // For fully read or unread blips, we don't need to load any history.
      // So the approach here is to find all the blips that are partially
      // read, and get the smallest version.

      // TODO(ohler): This should be getOrCreateAndConnect(), so that we can avoid
      // reconstructing the state of the wavelet that we just created.  But
      // snapshot caching would help with this as well, so we should probably do
      // that first.
      SlobId udwId = waveletCreator.getOrCreateUdw(convObjectId);
      Pair<ConnectResult, String> udwPair;
      try {
        udwPair = udwStore.connect(udwId, clientId);
      } catch (SlobNotFoundException e) {
        throw new RuntimeException("UDW disappeared right after getOrCreateUdw(): " + udwId);
      }
      ConnectResult udwResult = udwPair.getFirst();
      WaveletName udwWaveletName = IdHack.udwWaveletNameFromConvObjectIdAndUdwObjectId(
          convObjectId, udwId);
      WaveletDataImpl udw = deserializeWavelet(udwWaveletName, udwPair.getSecond());
      WalkaroundWaveletSnapshot udwSnapshot = serializer.createWaveletMessage(udw);
      LoadedUdw loadedUdw = new LoadedUdw(udwId, udwResult, udwSnapshot);
      if (!enableDiffOnOpen) {
        return waveWithoutDiffs(convObjectId, convResult, convWavelet, loadedUdw);
      }

      StringMap<Long> lastReadVersions = getLastReadVersions(udw, convWavelet);

      // The intermediate revision we'll load our wave in, as a simple optimization
      // that avoids loading most of the history in many use cases. We can try to
      // be smarter about this eventually.
      long intermediateVersion = getMinReadVersion(convWavelet, lastReadVersions);
      if (intermediateVersion <= 0 || intermediateVersion > convVersion) {
        throw new AssertionError("Invalid intermediateVersion " + intermediateVersion
          + ", conv version = " + convVersion);
      }

      String intermediateSnapshot;
      if (intermediateVersion == convVersion) {
        intermediateSnapshot = rawConvSnapshot;
      } else {
        try {
          intermediateSnapshot = convStore.loadAtVersion(convObjectId, intermediateVersion);
        } catch (SlobNotFoundException e) {
          throw new RuntimeException(
              "Conv object disappeared when trying to load intermediate version: " + convObjectId);
        }
      }
      WaveletDataImpl intermediateWavelet = deserializeWavelet(convWaveletName,
          intermediateSnapshot);

      Assert.check(intermediateWavelet.getVersion() == intermediateVersion);

      // We have to stop getting the history at conv version, because we're not
      // computing the metadata again for any concurrent ops that got added
      // since we loaded the convResult - so we don't want them getting added
      // into our diff snapshot. We can let the client catch up instead.
View Full Code Here

      });

  public static WaveletDataImpl buildWaveletFromInitialOps(WaveletName waveletName,
      List<WaveletOperation> ops, DocumentFactory<?> docFactory) throws OperationException {
    Preconditions.checkArgument(!ops.isEmpty(), "Empty list of ops");
    WaveletDataImpl wavelet = newWaveletFromInitialOp(waveletName, ops.get(0), docFactory);
    applyOps(wavelet, ops);
    return wavelet;
  }
View Full Code Here

      WaveletName waveletName, WaveletOperation initialOp, DocumentFactory<?> docFactory) {
    ParticipantId creator = initialOp.getContext().getCreator();
    Preconditions.checkNotNull(creator, "Null creator");
    long createTime = initialOp.getContext().getTimestamp();

    return new WaveletDataImpl(waveletName.waveletId, creator, createTime,
        0, HashedVersion.unsigned(0),
        createTime, waveletName.waveId, docFactory);
  }
View Full Code Here

    final WaveViewDataImpl waveData = WaveViewDataImpl.create(IdHack.FAKE_WAVELET_NAME.waveId);
    final FakeDocument.Factory docFactory = BasicFactories.fakeDocumentFactory();
    WaveletFactory<OpBasedWavelet> waveletFactory = new WaveletFactory<OpBasedWavelet>() {
      @Override
      public OpBasedWavelet create(WaveId waveId, WaveletId waveletId, ParticipantId creator) {
        final WaveletDataImpl data = new WaveletDataImpl(
            waveletId,
            creator,
            creationTime,
            0L,
            HashedVersion.unsigned(0),
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.wave.data.impl.WaveletDataImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.