use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class PipelineResource method update.
@ApiOperation(value = "Modify a processing pipeline", notes = "It can take up to a second until the change is applied")
@Path("/{id}")
@PUT
@AuditEvent(type = PipelineProcessorAuditEventTypes.PIPELINE_UPDATE)
public PipelineSource update(@ApiParam(name = "id") @PathParam("id") String id, @ApiParam(name = "pipeline", required = true) @NotNull PipelineSource update) throws NotFoundException {
checkPermission(PipelineRestPermissions.PIPELINE_EDIT, id);
final PipelineDao dao = pipelineService.load(id);
final Pipeline pipeline;
try {
pipeline = pipelineRuleParser.parsePipeline(update.id(), update.source());
} catch (ParseException e) {
throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(e.getErrors()).build());
}
final PipelineDao toSave = dao.toBuilder().title(pipeline.name()).description(update.description()).source(update.source()).modifiedAt(DateTime.now(DateTimeZone.UTC)).build();
final PipelineDao savedPipeline = pipelineService.save(toSave);
return PipelineSource.fromDao(pipelineRuleParser, savedPipeline);
}
use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class PipelineFacade method delete.
@Override
public void delete(PipelineDao nativeEntity) {
final Set<PipelineConnections> pipelineConnections = connectionsService.loadByPipelineId(nativeEntity.id());
for (PipelineConnections connections : pipelineConnections) {
final Set<String> pipelineIds = connections.pipelineIds().stream().filter(pipelineId -> !pipelineId.equals(nativeEntity.id())).collect(Collectors.toSet());
if (pipelineIds.isEmpty()) {
LOG.trace("Removing pipeline connections for stream {}", connections.streamId());
connectionsService.delete(connections.streamId());
} else {
final PipelineConnections newConnections = connections.toBuilder().pipelineIds(pipelineIds).build();
LOG.trace("Saving updated pipeline connections: {}", newConnections);
connectionsService.save(newConnections);
}
}
pipelineService.delete(nativeEntity.id());
}
Aggregations