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


Java ProtocolWaveletDelta.getOperationCount方法代码示例

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


在下文中一共展示了ProtocolWaveletDelta.getOperationCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: submitRequest

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入方法依赖的package包/类
@Timed
@Override
public void submitRequest(WaveletName waveletName, ProtocolWaveletDelta delta, final SubmitRequestCallback callback) {
  Preconditions.checkState(initialized, "Wave server not yet initialized");
  if (delta.getOperationCount() == 0) {
    callback.onFailure(ReturnCode.BAD_REQUEST,
        "Empty delta at version " + delta.getHashedVersion().getVersion());
    return;
  }

  // The serialised version of this delta happens now.  This should be the only place, ever!
  ProtocolSignedDelta signedDelta =
      certificateManager.signDelta(ByteStringMessage.serializeMessage(delta));

  submitDelta(waveletName, delta, signedDelta, new SubmitResultCallback() {
    @Override
    public void onFailure(FederationError errorMessage) {
      callback.onFailure(ReturnCode.INTERNAL_ERROR, errorMessage.getErrorMessage());
    }

    @Override
    public void onSuccess(int operationsApplied,
        ProtocolHashedVersion hashedVersionAfterApplication, long applicationTimestamp) {
      callback.onSuccess(operationsApplied,
          OperationSerializer.deserialize(hashedVersionAfterApplication),
          applicationTimestamp);
    }
  });
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:30,代码来源:WaveServerImpl.java

示例4: submitRequest

import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //导入方法依赖的package包/类
@Override
public void submitRequest(WaveletName waveletName, ProtocolWaveletDelta delta,
    final SubmitRequestListener listener) {
  Preconditions.checkState(initialized, "Wave server not yet initialized");
  if (delta.getOperationCount() == 0) {
    listener.onFailure("Empty delta at version " + delta.getHashedVersion().getVersion());
    return;
  }

  // The serialised version of this delta happens now.  This should be the only place, ever!
  ProtocolSignedDelta signedDelta =
      certificateManager.signDelta(ByteStringMessage.serializeMessage(delta));

  submitDelta(waveletName, delta, signedDelta, new SubmitResultListener() {
    @Override
    public void onFailure(FederationError errorMessage) {
      listener.onFailure(errorMessage.getErrorMessage());
    }

    @Override
    public void onSuccess(int operationsApplied,
        ProtocolHashedVersion hashedVersionAfterApplication, long applicationTimestamp) {
      listener.onSuccess(operationsApplied,
          CoreWaveletOperationSerializer.deserialize(hashedVersionAfterApplication),
          applicationTimestamp);
    }
  });
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:29,代码来源:WaveServerImpl.java


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