sourceInstanceFactory.parseUnchecked(requireParameter(req, "instance"));
// Rather than enqueueing just one interval 2008-01-01 to 2013-01-01, we
// split that interval into random parts. See the note on randomization
// in FindRemoteWavesProcessor.
log.info("Enqueueing find waves tasks");
@Nullable ImportSettings autoImportSettings;
if ("findwaves".equals(action)) {
autoImportSettings = null;
} else {
autoImportSettings = new ImportSettingsGsonImpl();
autoImportSettings.setSynthesizeHistory(!preserveHistory);
if ("private".equals(requireParameter(req, "sharingmode"))) {
autoImportSettings.setSharingMode(ImportSharingMode.PRIVATE);
} else if ("shared".equals(requireParameter(req, "sharingmode"))) {
autoImportSettings.setSharingMode(ImportSharingMode.SHARED);
} else if ("privateunlessparticipant".equals(requireParameter(req, "sharingmode"))) {
autoImportSettings.setSharingMode(ImportSharingMode.PRIVATE_UNLESS_PARTICIPANT);
} else {
throw new BadRequestException("Bad sharingmode");
}
}
enqueueTasks(findProcessor.get().makeRandomTasksForInterval(instance,
DaysSinceEpoch.fromYMD(2008, 1, 1),
DaysSinceEpoch.fromYMD(2013, 1, 1),
autoImportSettings));
} 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);
}