当前位置: 首页>>代码示例>>Java>>正文


Java ProtocolWaveletDelta类代码示例

本文整理汇总了Java中org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta的典型用法代码示例。如果您正苦于以下问题:Java ProtocolWaveletDelta类的具体用法?Java ProtocolWaveletDelta怎么用?Java ProtocolWaveletDelta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProtocolWaveletDelta类属于org.waveprotocol.wave.federation.Proto包,在下文中一共展示了ProtocolWaveletDelta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertDelta

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
/**
 * Replaces domain in deltas for Add/Remove participant operations.
 *
 * @param delta source delta
 * @param waveDomain target wave domain
 * @return delta for waveDomain if WaveDoamin is not null, otherwise source delta.
 * @throws InvalidParticipantAddress if there is a problem with deserialization of participant id.
 */
public static ProtocolWaveletDelta convertDelta(ProtocolWaveletDelta delta,
    String waveDomain) throws InvalidParticipantAddress {
  if (waveDomain != null) {
    ProtocolWaveletDelta.Builder newDelta = ProtocolWaveletDelta.newBuilder(delta);
    ParticipantId author = convertParticipantId(delta.getAuthor(), waveDomain);
    newDelta.setAuthor(author.getAddress());
    for (int i = 0; i < delta.getOperationCount(); i++) {
      ProtocolWaveletOperation op = delta.getOperation(i);
      ProtocolWaveletOperation.Builder newOp = ProtocolWaveletOperation.newBuilder(op);
      if (op.hasAddParticipant()) {
        convertAddParticipantOperation(newOp, op, waveDomain);
      } else if (op.hasRemoveParticipant()) {
        convertRemoveParticipantOperation(newOp, op, waveDomain);
      }
      // TODO(user) release convert for other operations.
      newDelta.setOperation(i, newOp);
    }
    return newDelta.build();
  } else {
    return delta;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:31,代码来源:DomainConverter.java

示例2: getUnacknowledgedDeltaVersion

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
@Timed
HashedVersion getUnacknowledgedDeltaVersion(WaveletName waveletName,
    HashedVersion startVersion, HashedVersion endVersion,
    final ProtocolWaveletDelta unacknowledgedDelta) throws WaveServerException {
  final AtomicReference<HashedVersion> unacknowledgedDeltaVersion = new AtomicReference<>();
  final ByteString unacknowledgedDeltaBytes = ByteStringMessage.serializeMessage(unacknowledgedDelta).getByteString();
  waveletProvider.getDeltaHistory(waveletName, startVersion, endVersion,
      new ThrowableReceiver<WaveletDeltaRecord, WaveServerException>() {

        @Override
        public boolean put(WaveletDeltaRecord delta) {
          if (delta.getAppliedDelta() != null
              && unacknowledgedDeltaBytes.equals(
              delta.getAppliedDelta().getMessage().getSignedOriginalDelta().getDelta())) {
            unacknowledgedDeltaVersion.set(delta.getResultingVersion());
            return false;
          }
          return true;
        }
      });
  return unacknowledgedDeltaVersion.get();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:ClientFrontendImpl.java

示例3: getDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
private void getDeltas(OperationContext context, WaveletName waveletName,
    ParticipantId participant, HashedVersion fromVersion, HashedVersion toVersion,
    RawDeltasListener listener) throws InvalidRequestException {
  final List<byte[]> deltaBytes = new LinkedList<byte[]>();
  final AtomicReference<HashedVersion> version = new AtomicReference<HashedVersion>();
  final AtomicInteger length = new AtomicInteger(0);
  context.getDeltas(waveletName, participant, fromVersion, toVersion, 
    new ThrowableReceiver<WaveletDeltaRecord, InvalidRequestException>() {
        @Override
        public boolean put(WaveletDeltaRecord delta) throws InvalidRequestException {
          ProtocolWaveletDelta protoDelta = OperationSerializer.serialize(delta.getTransformedDelta());
          byte[] bytes = protoDelta.toByteArray();
          deltaBytes.add(bytes);
          version.set(delta.getResultingVersion());
          return length.addAndGet(bytes.length) < GET_HISTORY_BYTES_LENGTH_LIMIT;
        }
     });
  listener.onSuccess(deltaBytes, OperationSerializer.serialize(version.get()).toByteArray());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:ExportDeltasService.java

示例4: testSubmitDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
public void testSubmitDeltas() {
  HashedVersion hashedVersionZero = HASH_FACTORY.createVersionZero(WAVELET_NAME);
  ObservableWaveletData waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX,
      hashedVersionZero, 0L);
  DocInitialization content = new DocInitializationBuilder().build();
  waveletData.createBlip("b+example", BOB, Collections.singletonList(BOB), content, 0L, 0, 0L, 0);

  RobotWaveletData wavelet = new RobotWaveletData(waveletData, hashedVersionZero);

  // Perform an operation that will be put into a delta
  wavelet.getOpBasedWavelet(BOB).addParticipant(ALEX);

  OperationResults results = mock(OperationResults.class);
  when(results.getOpenWavelets()).thenReturn(Collections.singletonMap(WAVELET_NAME, wavelet));

  SubmitRequestCallback requestListener = mock(SubmitRequestCallback.class);
  OperationUtil.submitDeltas(results, waveletProvider, requestListener);

  verify(waveletProvider).submitRequest(
      eq(WAVELET_NAME), any(ProtocolWaveletDelta.class), eq(requestListener));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:OperationUtilTest.java

示例5: testSignature_authorNotMatching

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
public void testSignature_authorNotMatching() throws Exception {
  ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
      .setHashedVersion(getProtocolHashedVersion())
      .setAuthor("[email protected]")
      .build();
  ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta);

  ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta);

  manager.storeSignerInfo(getSignerInfo().toProtoBuf());

  try {
    manager.verifyDelta(signedDelta);
    fail("expected exception, but didn't get it");
  } catch (SignatureException e) {
    // expected
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:19,代码来源:CertificateManagerImplTest.java

示例6: assertReversible

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
/**
 * Assert that an operation is unchanged when serialised then deserialised.
 *
 * @param op operation to check
 */
private static void assertReversible(WaveletOperation op) {
  // Test both (de)serialising a single operation...
  assertEquals(op, OperationSerializer.deserialize(OperationSerializer.serialize(op), OP_CONTEXT));

  List<WaveletOperation> ops = ImmutableList.of(op, op, op);
  ParticipantId author = new ParticipantId("[email protected]");
  HashedVersion hashedVersion = HashedVersion.unsigned(0);
  WaveletDelta delta = new WaveletDelta(author, hashedVersion, ops);
  ProtocolWaveletDelta serialized = OperationSerializer.serialize(delta);
  WaveletDelta deserialized = OperationSerializer.deserialize(serialized);
  assertEquals(hashedVersion.getVersion(), serialized.getHashedVersion().getVersion());
  assertTrue(Arrays.equals(hashedVersion.getHistoryHash(),
      serialized.getHashedVersion().getHistoryHash().toByteArray()));
  assertDeepEquals(delta, deserialized);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:WaveletOperationSerializerTest.java

示例7: getDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
private void getDeltas(OperationContext context, WaveletName waveletName,
    ParticipantId participant, HashedVersion fromVersion, HashedVersion toVersion,
    RawDeltasListener listener) throws InvalidRequestException {
  final List<byte[]> deltaBytes = new LinkedList<byte[]>();
  final AtomicReference<HashedVersion> version = new AtomicReference<HashedVersion>();
  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;
        }
      });
  listener.onSuccess(deltaBytes, CoreWaveletOperationSerializer.serialize(version.get()).toByteArray());
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:20,代码来源:ExportDeltasService.java

示例8: testSubmitDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
public void testSubmitDeltas() {
  HashedVersion hashedVersionZero = HASH_FACTORY.createVersionZero(WAVELET_NAME);
  ObservableWaveletData waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX,
      hashedVersionZero, 0L);
  DocInitialization content = new DocInitializationBuilder().build();
  waveletData.createDocument("b+example", BOB, Collections.singletonList(BOB), content, 0L, 0);

  RobotWaveletData wavelet = new RobotWaveletData(waveletData, hashedVersionZero);

  // Perform an operation that will be put into a delta
  wavelet.getOpBasedWavelet(BOB).addParticipant(ALEX);

  OperationResults results = mock(OperationResults.class);
  when(results.getOpenWavelets()).thenReturn(Collections.singletonMap(WAVELET_NAME, wavelet));

  SubmitRequestListener requestListener = mock(SubmitRequestListener.class);
  OperationUtil.submitDeltas(results, waveletProvider, requestListener);

  verify(waveletProvider).submitRequest(
      eq(WAVELET_NAME), any(ProtocolWaveletDelta.class), eq(requestListener));
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:22,代码来源:OperationUtilTest.java

示例9: submitDeltaToNewWavelet

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
private void submitDeltaToNewWavelet(WaveletName name, ParticipantId user,
    WaveletOperation... ops) throws Exception {

  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);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:19,代码来源:SimpleSearchProviderImplTest.java

示例10: submitDeltaToNewWavelet

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
private void submitDeltaToNewWavelet(WaveletName name, ParticipantId user,
    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) {
      // Wavelet was submitted.
    }

    @Override
    public void onFailure(String errorMessage) {
      fail("Could not submit callback");
    }
  });
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:27,代码来源:WaveServerTest.java

示例11: assertReversible

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
/**
 * Assert that an operation is unchanged when serialised then deserialised.
 *
 * @param op operation to check
 */
private static void assertReversible(WaveletOperation op) {
  // Test both (de)serialising a single operation...
  assertEquals(op, CoreWaveletOperationSerializer.deserialize(
      CoreWaveletOperationSerializer.serialize(op), OP_CONTEXT));

  List<WaveletOperation> ops = ImmutableList.of(op, op, op);
  ParticipantId author = new ParticipantId("[email protected]");
  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);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:22,代码来源:WaveletOperationSerializerTest.java

示例12: convertDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
/**
 * Converts all history deltas.
 *
 * @param deltas source deltas
 * @param waveDomain target wave domain
 * @return deltas for waveDomain if WaveDoamin is not null, otherwise source deltas.
 * @throws InvalidParticipantAddress if there is a problem with deserialization of participant id.
 */
public static List<ProtocolWaveletDelta> convertDeltas(List<ProtocolWaveletDelta> deltas,
    String waveDomain) throws InvalidParticipantAddress {
  if (waveDomain != null) {
    List<ProtocolWaveletDelta> targetDeltas = new LinkedList<ProtocolWaveletDelta>();
    for (ProtocolWaveletDelta delta : deltas) {
      targetDeltas.add(DomainConverter.convertDelta(delta, waveDomain));
    }
    return targetDeltas;
  } else {
    return deltas;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:DomainConverter.java

示例13: parseDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
public static List<ProtocolWaveletDelta> parseDeltas(List<byte[]> rawDeltas)
    throws InvalidProtocolBufferException {
  List<ProtocolWaveletDelta> deltas = new ArrayList<ProtocolWaveletDelta>();
  for (byte[] delta : rawDeltas) {
    deltas.add(ProtocolWaveletDelta.parseFrom(delta));
  }
  return deltas;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:9,代码来源:DeltaParser.java

示例14: getAttachemntIds

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
/**
 * Extract attachment ids from operations.
 */
public static Set<AttachmentId> getAttachemntIds(ProtocolWaveletDelta delta) {
  Set<AttachmentId> ids = new HashSet<AttachmentId>();
  for (int i=0; i < delta.getOperationCount(); i++) {
    ProtocolWaveletOperation op = delta.getOperation(i);
    if (op.hasMutateDocument()) {
      MutateDocument doc = op.getMutateDocument();
      for (int c = 0; c < doc.getDocumentOperation().getComponentCount(); c++) {
        Component comp = doc.getDocumentOperation().getComponent(c);
        ElementStart start = comp.getElementStart();
        if (ImageConstants.TAGNAME.equals(start.getType())) {
          for (int a=0; a < start.getAttributeCount(); a++) {
            Component.KeyValuePair attr = start.getAttribute(a);
            if (ImageConstants.ATTACHMENT_ATTRIBUTE.equals(attr.getKey())) {
              try {
                ids.add(AttachmentId.deserialise(attr.getValue()));
              } catch (InvalidIdException ex) {
                Console.error("Invalid attachment Id " + attr.getValue(), ex);
              }
            }
          }
        }
      }
    }
  }
  return ids;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:30,代码来源:DeltaParser.java

示例15: exportDeltas

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入依赖的package包/类
private void exportDeltas(WaveId waveId, WaveletId waveletId, ProtocolHashedVersion lastVersion,
    Set<AttachmentId> attachmentIds) throws IOException {
  HashedVersion zeroVersion = HASH_FACTORY.createVersionZero(WaveletName.of(waveId, waveletId));
  ProtocolHashedVersion version = OperationSerializer.serialize(zeroVersion);
  for (int fetchNum = 0; version.getVersion() != lastVersion.getVersion(); fetchNum++) {
    Console.print("    getting deltas from version " + version.getVersion() + " ...");
    final List<byte[]> deltas = Lists.newArrayList();
    final AtomicReference<byte[]> targetVersion = new AtomicReference<byte[]>();
    api.exportRawDeltas(waveId, waveletId,
        version.toByteArray(), lastVersion.toByteArray(), rpcServerUrl,
        new RawDeltasListener() {

          @Override
          public void onSuccess(List<byte[]> rawDeltas, byte[] rawTargetVersion) {
            deltas.addAll(rawDeltas);
            targetVersion.set(rawTargetVersion);
          }

          @Override
          public void onFailure(String message) {
            Console.error(search);
          }
        });
    if (deltas.isEmpty()) {
      Console.println(" empty response");
      continue;
    }
    version = ProtocolHashedVersion.parseFrom(targetVersion.get());
    Console.println(" Ok, got to version " + version.getVersion());
    writeDeltasToFile(waveId, waveletId, deltas, fetchNum);
    for (byte[] delta : deltas) {
      attachmentIds.addAll(DeltaParser.getAttachemntIds(ProtocolWaveletDelta.parseFrom(delta)));
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:36,代码来源:WaveExport.java


注:本文中的org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。