} else if ("importwavelet".equals(action)) {
SourceInstance instance =
sourceInstanceFactory.parseUnchecked(requireParameter(req, "instance"));
WaveId waveId = WaveId.deserialise(requireParameter(req, "waveid"));
WaveletId waveletId = WaveletId.deserialise(requireParameter(req, "waveletid"));
ImportWaveletTask task = new ImportWaveletTaskGsonImpl();
task.setInstance(instance.serialize());
task.setWaveId(waveId.serialise());
task.setWaveletId(waveletId.serialise());
ImportSettings settings = new ImportSettingsGsonImpl();
if ("private".equals(requireParameter(req, "sharingmode"))) {
settings.setSharingMode(ImportSettings.ImportSharingMode.PRIVATE);
} else if ("shared".equals(requireParameter(req, "sharingmode"))) {
settings.setSharingMode(ImportSettings.ImportSharingMode.SHARED);
} else {
throw new BadRequestException("Unexpected import sharing mode");
}
settings.setSynthesizeHistory(!preserveHistory);
task.setSettings(settings);
@Nullable String existingSlobIdToIgnore = optionalParameter(req, "ignoreexisting", null);
if (existingSlobIdToIgnore != null) {
task.setExistingSlobIdToIgnore(existingSlobIdToIgnore);
}
final ImportTaskPayload payload = new ImportTaskPayloadGsonImpl();
payload.setImportWaveletTask(task);
log.info("Enqueueing import task for " + waveId
+ "; synthesizeHistory=" + task.getSettings().getSynthesizeHistory());
enqueueTasks(ImmutableList.of(payload));
} else if ("canceltasks".equals(action)) {
log.info("Cancelling all tasks for " + userId);
try {
new RetryHelper().run(new RetryHelper.VoidBody() {