} catch (WaveServerException e1) {
waveletIds = Sets.newHashSet();
LOG.warning("Failed to retrieve visible wavelets for " + loggedInUser, e1);
}
for (WaveletId waveletId : waveletIds) {
WaveletName waveletName = WaveletName.of(waveId, waveletId);
// Ensure that implicit participants will also receive updates.
// TODO (Yuri Z.) If authorizing participant was removed from the wave
// (the shared domain participant), then all implicit participant that
// were authorized should be unsubsrcibed.
waveletInfo.notifyAddedImplcitParticipant(waveletName, loggedInUser);
// The WaveletName by which the waveletProvider knows the relevant deltas
// TODO(anorth): if the client provides known wavelets, calculate
// where to start sending deltas from.
CommittedWaveletSnapshot snapshotToSend;
// Send a snapshot of the current state.
// TODO(anorth): calculate resync point if the client already knows
// a snapshot.
try {
snapshotToSend = waveletProvider.getSnapshot(waveletName);
} catch (WaveServerException e) {
LOG.warning("Failed to retrieve snapshot for wavelet " + waveletName, e);
openListener.onFailure("Wave server failure retrieving wavelet");
return;
}
LOG.info("snapshot in response is: " + (snapshotToSend != null));
if (snapshotToSend == null) {
// Send deltas.
openListener.onUpdate(waveletName, snapshotToSend, DeltaSequence.empty(),
null, null, channelId);
} else {
// Send the snapshot.
openListener.onUpdate(waveletName, snapshotToSend, DeltaSequence.empty(),
snapshotToSend.committedVersion, null, channelId);
}
}
WaveletName dummyWaveletName = createDummyWaveletName(waveId);
if (waveletIds.size() == 0) {
// Send message with just the channel id.
LOG.info("sending just a channel id for " + dummyWaveletName);
openListener.onUpdate(dummyWaveletName, null, DeltaSequence.empty(), null, null,
channelId);