本文整理汇总了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;
}
}
示例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;
}
示例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);
}
});
}
示例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);
}
});
}