當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。