ConvMetadata metadata = convMetadataStore.get(tx, convId);
Assert.check(metadata.hasImportMetadata(), "%s: Metadata has no import: %s",
convId, metadata);
Assert.check(metadata.getImportMetadata().getImportFinished(),
"%s: still importing: %s", convId, metadata);
MutationLog l = convSlobFacilities.getMutationLogFactory().create(tx, convId);
StateAndVersion stateAndVersion = l.reconstruct(null);
Assert.check(stateAndVersion.getVersion() > 0, "%s at version 0: %s",
convId, stateAndVersion);
// TODO(ohler): use generics to avoid the cast
ReadableWaveletObject state = (ReadableWaveletObject) stateAndVersion.getState();
if (state.getParticipants().contains(importingUser)) {
log.info(importingUser + " is a participant at version "
+ stateAndVersion.getVersion());
return;
}
WaveletOperation op =
HistorySynthesizer.newAddParticipant(importingUser.getAddress(),
// We preserve last modified time to avoid re-ordering people's inboxes
// just because another participant imported.
state.getLastModifiedMillis(),
importingUser.getAddress());
log.info(importingUser + " is not a participant at version "
+ stateAndVersion.getVersion() + ", adding " + op);
MutationLog.Appender appender = l.prepareAppender().getAppender();
try {
appender.append(
new ChangeData<String>(getFakeClientId(), SERIALIZER.serializeDelta(op)));
} catch (ChangeRejected e) {
throw new RuntimeException("Appender rejected AddParticipant: " + op);