callback.onFailure(FederationErrors.badRequest(
"Couldn't decode wavelet name: " + waveletUpdate.attributeValue("wavelet-name")));
continue;
}
WaveletFederationListener listener =
updatesListenerFactory.listenerForDomain(waveletName.waveletId.getDomain());
// Submit all applied deltas to the domain-focused listener.
ImmutableList.Builder<ByteString> builder = ImmutableList.builder();
for (Element appliedDeltaElement :
XmppUtil.toSafeElementList(waveletUpdate.elements("applied-delta"))) {
builder.add(Base64Util.decode(appliedDeltaElement.getText()));
}
ImmutableList<ByteString> deltas = builder.build();
if (!deltas.isEmpty()) {
callbackCount.incrementAndGet(); // Increment required callbacks.
listener.waveletDeltaUpdate(waveletName, deltas, callback);
}
// Optionally submit any received last committed notice.
Element commitNoticeElement = waveletUpdate.element("commit-notice");
if (commitNoticeElement != null) {
ProtocolHashedVersion version = ProtocolHashedVersion.newBuilder()
.setHistoryHash(Base64Util.decode(commitNoticeElement.attributeValue("history-hash")))
.setVersion(Long.parseLong(commitNoticeElement.attributeValue("version"))).build();
callbackCount.incrementAndGet(); // Increment required callbacks.
listener.waveletCommitUpdate(waveletName, version, callback);
}
}
// Release sentinel so that 'expected' callbacks from the WS don't invoke
// sending a receipt.