mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
Never change the state of system definitions on edit (#24780)
* Never change the state of system definitions on edit
This commit is contained in:
6
changelog/unreleased/pr-24780.toml
Normal file
6
changelog/unreleased/pr-24780.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
type = "fixed"
|
||||
message = "Removed unnecessary automatic disabling of system event definitions during editing operations."
|
||||
|
||||
issues = ["22946"]
|
||||
pulls = ["24780"]
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.graylog2.audit.AuditEventSender;
|
||||
import org.graylog2.audit.jersey.AuditEvent;
|
||||
import org.graylog2.audit.jersey.NoAuditEvent;
|
||||
import org.graylog2.database.PaginatedList;
|
||||
import org.graylog2.database.entities.NonDeletableSystemScope;
|
||||
import org.graylog2.database.entities.source.DBEntitySourceService;
|
||||
import org.graylog2.database.utils.SourcedMongoEntityUtils;
|
||||
import org.graylog2.plugin.rest.PluginRestResource;
|
||||
@@ -357,8 +358,14 @@ public class EventDefinitionsResource extends RestResource implements PluginRest
|
||||
if (result.failed()) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(result).build();
|
||||
}
|
||||
|
||||
dto = dto.toBuilder().state(schedule ? EventDefinition.State.ENABLED : EventDefinition.State.DISABLED).build();
|
||||
if (NonDeletableSystemScope.NAME.equals(dto.scope())) {
|
||||
//never change the state of system definitions, as the state cannot be later on changed in the UI
|
||||
dto = dto.toBuilder().build();
|
||||
} else {
|
||||
dto = dto.toBuilder()
|
||||
.state(schedule ? EventDefinition.State.ENABLED : EventDefinition.State.DISABLED)
|
||||
.build();
|
||||
}
|
||||
recentActivityService.update(definitionId, GRNTypes.EVENT_DEFINITION, userContext.getUser());
|
||||
return Response.ok().entity(eventDefinitionHandler.update(dto, schedule)).build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user