Examples of WaveletOperation


Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

    return new WaveletBlipOperation(id,
        new BlipContentOperation(opContext(time, version), new DocOpBuilder().build()));
  }

  private TransformedWaveletDelta delta(WaveletOperation... ops) {
    WaveletOperation last = ops[ops.length - 1];
    WaveletOperationContext ctx = last.getContext();
    return new TransformedWaveletDelta(
        ctx.getCreator(), ctx.getHashedVersion(), ctx.getTimestamp(), Arrays.asList(ops));
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

      for (int j = 0; j < coreWaveletOperations.size(); ++j) {
        boolean isLast = isLastOfOuter && (j == coreWaveletOperations.size() - 1);
        WaveletOperationContext opContext =
            contextForCreator(pair.creator, versionIncrement, hashedVersion, isLast);
        WaveletOperation waveletOps =
            coreWaveletOpsToWaveletOps(coreWaveletOperations.get(j), opContext);
        ret.add(waveletOps);
      }
    }
    return ret;
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

    Preconditions.checkState(delta.getAppliedAtVersion() == wavelet.getVersion(),
        "Delta's version %s doesn't apply to wavelet at %s", delta.getAppliedAtVersion(),
        wavelet.getVersion());

    List<WaveletOperation> reverseOps = new ArrayList<WaveletOperation>();
    WaveletOperation lastOp = null;
    int opsApplied = 0;
    try {
      for (WaveletOperation op : delta) {
        lastOp = op;
        List<? extends WaveletOperation> reverseOp = op.applyAndReturnReverse(wavelet);
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

  private WaveletOperation waveletOp(DocOp docOp) {
    return new WaveletBlipOperation(DOC_ID, new BlipContentOperation(DEFAULT_CONTEXT, docOp));
  }

  public void testBasicTransform() throws Exception {
    WaveletOperation op1 = waveletOp(new DocOpBuilder().characters("a").build());
    WaveletOperation op2 = waveletOp(new DocOpBuilder().characters("b").build());
    WaveletOperation expectedTransformedOp1 =
        waveletOp(new DocOpBuilder().characters("a").retain(1).build());
    List<String> result = MODEL.transform(
        ImmutableList.of(new ChangeData<String>(CLIENT_ID_1, SERIALIZER.serializeDelta(op1))),
        ImmutableList.of(new ChangeData<String>(CLIENT_ID_2, SERIALIZER.serializeDelta(op2))));
    WaveletOperation resultOp = SERIALIZER.deserializeDelta(Iterables.getOnlyElement(result));
    assertEquals(expectedTransformedOp1, resultOp);
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

    }

    @Override
    public void apply(ChangeData<String> change) throws ChangeRejected {
      cachedSnapshot = null;
      WaveletOperation op;
      try {
        op = serializer.deserializeDelta(change.getPayload());
      } catch (MessageException e) {
        throw new ChangeRejected("Malformed op: " + change, e);
      }

      if (wavelet == null) {
        try {
          wavelet = WaveletUtil.buildWaveletFromInitialOps(
              IdHack.FAKE_WAVELET_NAME, Collections.singletonList(op));
        } catch (OperationException e) {
          throw new ChangeRejected("Invalid initial op: " + op, e);
        }
      } else {
        try {
          op.apply(wavelet);
        } catch (OperationException e) {
          // Operation failed. The wavelet is still intact, however, so just
          // report the failure and continue on.
          throw new ChangeRejected("Invalid op at version " + wavelet.getVersion() + ": " + op, e);
        }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

    public void run(CheckedTransaction tx, SlobId convId, List<ChangeData<String>> newDeltas,
        long resultingVersion, ReadableSlob resultingState)
        throws RetryableFailure, PermanentFailure {
      ImmutableSet.Builder<ParticipantId> out = ImmutableSet.builder();
      for (ChangeData<String> delta : newDeltas) {
        WaveletOperation op;
        try {
          op = SERIALIZER.deserializeDelta(delta.getPayload());
        } catch (MessageException e) {
          throw new RuntimeException("Malformed op: " + delta, e);
        }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

  @Override
  public WaveletOperation receive() {
    if (versionUpdatesBuffer.isEmpty()) {
      return null;
    }
    WaveletOperation maybeOp = versionUpdatesBuffer.remove();
    return maybeOp != null ? maybeOp : channel.receive();
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

                if (state.getParticipants().contains(importingUser)) {
                  log.info(importingUser + " is a participant at version "
                      + stateAndVersion.getVersion());
                  return;
                }
                WaveletOperation op =
                    HistorySynthesizer.newAddParticipant(importingUser.getAddress(),
                        // We preserve last modified time to avoid re-ordering people's inboxes
                        // just because another participant imported.
                        state.getLastModifiedMillis(),
                        importingUser.getAddress());
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

                Preconditions.checkState(badOp.getContext().getTimestamp() == -1,
                    "Unexpected timestamp: %s in delta %s", badOp, delta);
                // TODO(ohler): Rename
                // CoreWaveletOperationSerializer.deserialize() to
                // deserializeWithNoTimestamp() or something.
                WaveletOperation withTimestamp = WaveletOperation.cloneOp(badOp,
                    new WaveletOperationContext(badOp.getContext().getCreator(),
                        rawDelta.getApplicationTimestamp(),
                        badOp.getContext().getVersionIncrement()));
                WaveletOperation converted =
                    converter.convertAndApply(convertGooglewaveToGmail(withTimestamp));
                //log.info(version + ": " + op + " -> " + converted);
                historyWriter.append(converted);
                version++;
              }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperation

  @Override
  public void addParticipant(ParticipantId participant) {
    if (!wavelet.getParticipants().contains(participant)) {
      // Authrorise and apply/send the op in separate stages to avoid sending
      // duplicate add-participant ops (authorise() may inject one).
      WaveletOperation addOp = new AddParticipant(createContext(), participant);
      WaveletOperation injectedOp = authorise(addOp);
      if (!addOp.equals(injectedOp)) {
        applyAndSend(addOp);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.