Package org.waveprotocol.wave.federation.Proto

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


        LOG.info("Get wavelet snapshot", ex);
        context.constructErrorResponse(operation, ex.toString());
        return;
      }
      for (byte[] deltaBytes : history) {
        ProtocolWaveletDelta delta;
        try {
          delta = ProtocolWaveletDelta.parseFrom(deltaBytes);
        } catch (InvalidProtocolBufferException ex) {
          throw new InvalidRequestException("Parse delta", operation, ex);
        }
        long currentVersion = 0;
        if (waveletSnapshot != null) {
          currentVersion = waveletSnapshot.snapshot.getVersion();
        }
        if (currentVersion == delta.getHashedVersion().getVersion()) {
          if (importedFromVersion == -1) {
            importedFromVersion = currentVersion;
          }
          ProtocolWaveletDelta newDelta;
          try {
            newDelta = setVersionHash(delta, waveletSnapshot, waveletName);
          } catch (InvalidParticipantAddress ex) {
            throw new InvalidRequestException("Convert delta", operation, ex);
          }
View Full Code Here


      WaveletOperation... ops) {
    HashedVersion version = V0_HASH_FACTORY.createVersionZero(name);

    WaveletDelta delta = new WaveletDelta(user, version, ImmutableList.copyOf(ops));

    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();

    waveServer.submitRequest(name, protoDelta, new SubmitRequestListener() {
      @Override
      public void onSuccess(int operationsApplied, HashedVersion hashedVersionAfterApplication,
          long applicationTimestamp) {
View Full Code Here

    assertEquals(waveletId.getDomain(), DOMAIN);
    assertEquals(IdUtil.split(waveletId.getId())[1], USER);
  }

  public void testConvertOfDelta() throws WaveletStateException, InvalidParticipantAddress {
    ProtocolWaveletDelta delta = DomainConverter.convertDelta(DELTA_ADD_USER, DOMAIN);
    assertEquals(USER, delta.getAuthor());
    assertEquals(USER, delta.getOperation(0).getAddParticipant());
  }
View Full Code Here

    final AtomicInteger length = new AtomicInteger(0);
    context.getDeltas(waveletName, participant, fromVersion, toVersion, new Receiver<TransformedWaveletDelta>() {

          @Override
          public boolean put(TransformedWaveletDelta delta) {
            ProtocolWaveletDelta protoDelta = CoreWaveletOperationSerializer.serialize(delta);
            byte[] bytes = protoDelta.toByteArray();
            deltaBytes.add(bytes);
            version.set(delta.getResultingVersion());
            return length.addAndGet(bytes.length) < GET_HISTORY_BYTES_LENGTH_LIMIT;
          }
        });
View Full Code Here

      SubmitRequestListener requestListener) {
    for (Entry<WaveletName, RobotWaveletData> entry : results.getOpenWavelets().entrySet()) {
      WaveletName waveletName = entry.getKey();
      RobotWaveletData w = entry.getValue();
      for (WaveletDelta delta : w.getDeltas()) {
        ProtocolWaveletDelta protocolDelta = CoreWaveletOperationSerializer.serialize(delta);
        waveletProvider.submitRequest(waveletName, protocolDelta, requestListener);
      }
    }
  }
View Full Code Here

    assertEquals(dar1.getResultingVersion(), dar2.getResultingVersion());
  }

  private ProtocolSignedDelta createProtocolSignedDelta(ProtocolWaveletOperation operation,
      HashedVersion protocolHashedVersion) {
    ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
        .setAuthor(AUTHOR)
        .setHashedVersion(CoreWaveletOperationSerializer.serialize(protocolHashedVersion))
        .addOperation(operation)
        .build();

    return ProtocolSignedDelta.newBuilder()
        .setDelta(delta.toByteString())
        .addSignature(SIGNATURE)
        .build();
  }
View Full Code Here

    List<WaveletOperation> ops =
        ImmutableList.of(UTIL.noOp(), UTIL.addParticipant(TestingConstants.OTHER_PARTICIPANT));
    TransformedWaveletDelta transformed = TransformedWaveletDelta.cloneOperations(
        TestingConstants.PARTICIPANT, resultingVersion, 1234567890, ops);

    ProtocolWaveletDelta serializedDelta = CoreWaveletOperationSerializer.serialize(transformed);

    ProtocolSignature signature =
        ProtocolSignature.newBuilder().setSignatureAlgorithm(SignatureAlgorithm.SHA1_RSA)
            .setSignatureBytes(ByteString.copyFrom(new byte[] {1, 2, 3})).setSignerId(
                ByteString.copyFromUtf8("somebody")).build();
View Full Code Here

  /*
   * TESTS
   */
  public void testSignature() throws Exception {
    ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
        .setHashedVersion(getProtocolHashedVersion())
        .setAuthor("bob@example.com")
        .build();
    ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta);

View Full Code Here

    assertEquals(canonicalDelta, compare);
  }

  public void testSignature_missingSignerInfo() throws Exception {
    ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
        .setHashedVersion(getProtocolHashedVersion())
        .setAuthor("bob@example.com")
        .build();
    ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta);
    manager = new CertificateManagerImpl(false, getSigner(), getVerifier(store, false), store);
View Full Code Here

      fail("expected UnknownSignerExeception, but got " + e);
    }
  }

  public void testSignature_authorNotMatching() throws Exception {
    ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
        .setHashedVersion(getProtocolHashedVersion())
        .setAuthor("bob@someotherdomain.com")
        .build();
    ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta);
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.