use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class InputServiceImpl method getMessageInput.
@Override
public MessageInput getMessageInput(Input io) throws NoSuchInputTypeException {
final Configuration configuration = new Configuration(io.getConfiguration());
final MessageInput input = messageInputFactory.create(io.getType(), configuration);
// Add all standard fields.
input.setTitle(io.getTitle());
input.setNodeId(io.getNodeId());
input.setCreatorUserId(io.getCreatorUserId());
input.setPersistId(io.getId());
input.setCreatedAt(io.getCreatedAt());
input.setContentPack(io.getContentPack());
input.setDesiredState(io.getDesiredState());
if (io.isGlobal()) {
input.setGlobal(true);
}
// Add static fields.
input.addStaticFields(io.getStaticFields());
return input;
}
use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class InputsResource method create.
@POST
@Timed
@ApiOperation(value = "Launch input on this node", response = InputCreated.class)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input type registered"), @ApiResponse(code = 400, message = "Missing or invalid configuration"), @ApiResponse(code = 400, message = "Type is exclusive and already has input running") })
@RequiresPermissions(RestPermissions.INPUTS_CREATE)
@AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_CREATE)
public Response create(@ApiParam(name = "JSON body", required = true) @Valid @NotNull InputCreateRequest lr) throws ValidationException {
try {
// TODO Configuration type values need to be checked. See ConfigurationMapConverter.convertValues()
final MessageInput messageInput = messageInputFactory.create(lr, getCurrentUser().getName(), lr.node());
messageInput.checkConfiguration();
final Input input = this.inputService.create(messageInput.asMap());
final String newId = inputService.save(input);
final URI inputUri = getUriBuilderToSelf().path(InputsResource.class).path("{inputId}").build(newId);
return Response.created(inputUri).entity(InputCreated.create(newId)).build();
} catch (NoSuchInputTypeException e) {
LOG.error("There is no such input type registered.", e);
throw new NotFoundException("There is no such input type registered.", e);
} catch (ConfigurationException e) {
LOG.error("Missing or invalid input configuration.", e);
throw new BadRequestException("Missing or invalid input configuration.", e);
}
}
use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class MessageInputFactory method create.
public MessageInput create(InputCreateRequest lr, String user, String nodeId) throws NoSuchInputTypeException {
final MessageInput input = create(lr.type(), new Configuration(lr.configuration()));
input.setTitle(lr.title());
input.setGlobal(lr.global());
input.setCreatorUserId(user);
input.setCreatedAt(Tools.nowUTC());
if (!lr.global())
input.setNodeId(nodeId);
return input;
}
Aggregations