NotFoundException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException,
org.graylog2.plugin.inputs.Extractor.ReservedFieldException {
final Configuration inputConfig = new Configuration(inputDescription.getConfiguration());
final DateTime createdAt = Tools.iso8601();
final MessageInput messageInput = inputRegistry.create(inputDescription.getType(), inputConfig);
messageInput.setTitle(inputDescription.getTitle());
messageInput.setGlobal(inputDescription.isGlobal());
messageInput.setCreatorUserId(userName);
messageInput.setCreatedAt(createdAt);
messageInput.setContentPack(bundleId);
messageInput.setConfiguration(inputConfig);
messageInput.checkConfiguration();
// Don't run if exclusive and another instance is already running.
if (messageInput.isExclusive() && inputRegistry.hasTypeRunning(messageInput.getClass())) {
final String error = "Type is exclusive and already has input running.";
LOG.error(error);
}
org.graylog2.inputs.Input mongoInput = new InputImpl(
buildMongoDbInput(UUID.randomUUID(), inputDescription, userName, createdAt, bundleId));
// Persist input.
final String persistId = inputService.save(mongoInput);
messageInput.setPersistId(persistId);
messageInput.initialize();
addStaticFields(messageInput, inputDescription.getStaticFields());
addExtractors(messageInput, inputDescription.getExtractors(), userName);
return messageInput;