Package org.waveprotocol.wave.federation.Proto

Examples of org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta


        .addSignature(getRealSignature())
        .build();
  }

  private ByteStringMessage<ProtocolWaveletDelta> getFakeDelta() throws Exception {
    ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
        .setHashedVersion(getProtocolHashedVersion())
        .setAuthor("bob@initech-corp.com")
        .build();
    return ByteStringMessage.serializeMessage(delta);
  }
View Full Code Here


  /**
   * Build an applied delta message from a POJO delta. The delta is not signed.
   */
  public static ByteStringMessage<ProtocolAppliedWaveletDelta> buildAppliedDelta(WaveletDelta delta,
      long applicationTimestamp) {
    ProtocolWaveletDelta protoDelta = CoreWaveletOperationSerializer.serialize(delta);
    ByteStringMessage<ProtocolWaveletDelta> deltaBytes =
        ByteStringMessage.serializeMessage(protoDelta);
    ProtocolSignedDelta signedDelta =
        ProtocolSignedDelta.newBuilder().setDelta(deltaBytes.getByteString()).build();
    return AppliedDeltaUtil.buildAppliedDelta(signedDelta, delta.getTargetVersion(), delta.size(),
View Full Code Here

    List<WaveletOperation> ops = ImmutableList.of(op, op, op);
    ParticipantId author = new ParticipantId("kalman@google.com");
    HashedVersion hashedVersion = HashedVersion.unsigned(0);
    WaveletDelta delta = new WaveletDelta(author, hashedVersion, ops);
    ProtocolWaveletDelta serialized = CoreWaveletOperationSerializer.serialize(delta);
    WaveletDelta deserialized = CoreWaveletOperationSerializer.deserialize(serialized);
    assertEquals(hashedVersion.getVersion(), serialized.getHashedVersion().getVersion());
    assertTrue(Arrays.equals(hashedVersion.getHistoryHash(),
        serialized.getHashedVersion().getHistoryHash().toByteArray()));
    assertDeepEquals(delta, deserialized);
  }
View Full Code Here

    HashedVersion version = V0_HASH_FACTORY.createVersionZero(name);
    WaveletDelta delta = new WaveletDelta(user, version, Arrays.asList(ops));
    addWaveletToUserView(name, user);


    ProtocolWaveletDelta protoDelta = CoreWaveletOperationSerializer.serialize(delta);

    // Submitting the request will require the certificate manager to sign the delta. We'll just
    // leave it unsigned.
    ProtocolSignedDelta signedProtoDelta =
        ProtocolSignedDelta.newBuilder().setDelta(protoDelta.toByteString()).build();

    LocalWaveletContainer wavelet = waveMap.getOrCreateLocalWavelet(name);
    wavelet.submitRequest(name, signedProtoDelta);
  }
View Full Code Here

      LOG.warning("Remote tried to submit to non-local wavelet " + waveletName);
      listener.onFailure(FederationErrors.badRequest("Non-local wavelet update"));
      return;
    }

    ProtocolWaveletDelta delta;
    try {
      delta = ByteStringMessage.parseProtocolWaveletDelta(signedDelta.getDelta()).getMessage();
    } catch (InvalidProtocolBufferException e) {
      LOG.warning("Submit request: Invalid delta protobuf. WaveletName: " + waveletName, e);
      listener.onFailure(FederationErrors.badRequest("Signed delta contains invalid delta"));
      return;
    }

    // Disallow creation of wavelets by remote users.
    if (delta.getHashedVersion().getVersion() == 0) {
      LOG.warning("Remote user tried to submit delta at version 0 - disallowed. " + signedDelta);
      listener.onFailure(FederationErrors.badRequest("Remote users may not create wavelets."));
      return;
    }
View Full Code Here

   * @throws InvalidHashException if delta hash sanity checks fail
   */
  private WaveletDeltaRecord transformAndApplyLocalDelta(ProtocolSignedDelta signedDelta)
      throws OperationException, InvalidProtocolBufferException, InvalidHashException,
      PersistenceException {
    ProtocolWaveletDelta protocolDelta =
        ByteStringMessage.parseProtocolWaveletDelta(signedDelta.getDelta()).getMessage();

    Preconditions.checkArgument(protocolDelta.getOperationCount() > 0, "empty delta");

    WaveletDelta transformed = maybeTransformSubmittedDelta(
        CoreWaveletOperationSerializer.deserialize(protocolDelta));

    // TODO(ljvderijk): a Clock needs to be injected here (Issue 104)
View Full Code Here

      targetDeltas = deltas;
      targetHistory = sourceHistory;
    }
    if (!targetDeltas.isEmpty()) {
      long fromVersion = targetDeltas.get(0).getHashedVersion().getVersion();
      ProtocolWaveletDelta lastDelta = targetDeltas.get(targetDeltas.size()-1);
      long toVersion = lastDelta.getHashedVersion().getVersion()+lastDelta.getOperationCount();
      Console.print("    send deltas " + fromVersion + "-" + toVersion + " ...");
      long importedFromVersion = api.importRawDeltas(targetWaveId, targetWaveletId, targetHistory, rpcServerUrl);
      if (fromVersion == importedFromVersion) {
        Console.println(" imported");
      } else if (importedFromVersion == -1) {
View Full Code Here

      for (ByteStringMessage<ProtocolAppliedWaveletDelta> appliedDelta : appliedDeltas) {
        LOG.info("Delta incoming: " + appliedDelta);

        // Log any illformed signed original deltas. TODO: Check if this can be removed.
        try {
          ProtocolWaveletDelta actualDelta = ProtocolWaveletDelta.parseFrom(
              appliedDelta.getMessage().getSignedOriginalDelta().getDelta());
          LOG.info("actual delta: " + actualDelta);
        } catch (InvalidProtocolBufferException e) {
          e.printStackTrace();
        }
View Full Code Here

        Set<ParticipantId> participants = new HashSet<ParticipantId>();
        if (wavelet != null) {
          participants.addAll(wavelet.accessSnapshot().getParticipants());
        }
        for (ProtocolAppliedWaveletDelta appliedDelta : deltas) {
          ProtocolWaveletDelta delta = ProtocolWaveletDelta.parseFrom(
              appliedDelta.getSignedOriginalDelta().getDelta());
          long currentVersion = 0;
          if (wavelet != null) {
            currentVersion = wavelet.getCurrentVersion().getVersion();
          }
          if (currentVersion == delta.getHashedVersion().getVersion()) {
            ProtocolWaveletDelta newDelta = convertDelta(delta, domain, wavelet, waveletName,
                participants);

            waveletProvider.submitRequest(waveletName, newDelta,
                new WaveletProvider.SubmitRequestListener() {
View Full Code Here

   * @throws InvalidHashException if delta hash sanity checks fail
   */
  private WaveletDeltaRecord transformAndApplyLocalDelta(ProtocolSignedDelta signedDelta)
      throws OperationException, InvalidProtocolBufferException, InvalidHashException,
      PersistenceException {
    ProtocolWaveletDelta protocolDelta =
        ByteStringMessage.parseProtocolWaveletDelta(signedDelta.getDelta()).getMessage();

    Preconditions.checkArgument(protocolDelta.getOperationCount() > 0, "empty delta");

    WaveletDelta transformed = maybeTransformSubmittedDelta(
        CoreWaveletOperationSerializer.deserialize(protocolDelta));

    // TODO(ljvderijk): a Clock needs to be injected here (Issue 104)
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta

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.