Search in sources :

Example 11 with GrokPatternEntity

use of org.graylog2.contentpacks.model.entities.GrokPatternEntity in project graylog2-server by Graylog2.

the class GrokPatternFacade method findExisting.

private Optional<NativeEntity<GrokPattern>> findExisting(EntityV1 entity) {
    final GrokPatternEntity grokPatternEntity = objectMapper.convertValue(entity.data(), GrokPatternEntity.class);
    final String name = grokPatternEntity.name();
    final String pattern = grokPatternEntity.pattern();
    final Optional<GrokPattern> grokPattern = grokPatternService.loadByName(name);
    grokPattern.ifPresent(existingPattern -> compareGrokPatterns(name, pattern, existingPattern.pattern()));
    return grokPattern.map(gp -> NativeEntity.create(entity.id(), gp.id(), TYPE_V1, gp.name(), gp));
}
Also used : GrokPattern(org.graylog2.grok.GrokPattern) GrokPatternEntity(org.graylog2.contentpacks.model.entities.GrokPatternEntity)

Aggregations

GrokPatternEntity (org.graylog2.contentpacks.model.entities.GrokPatternEntity)11 Entity (org.graylog2.contentpacks.model.entities.Entity)8 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)8 Test (org.junit.Test)7 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)6 GrokPattern (org.graylog2.grok.GrokPattern)6 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 HashMap (java.util.HashMap)3 ValueReference (org.graylog2.contentpacks.model.entities.references.ValueReference)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)2 DivergingEntityConfigurationException (org.graylog2.contentpacks.exceptions.DivergingEntityConfigurationException)2 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Graph (com.google.common.graph.Graph)1 GraphBuilder (com.google.common.graph.GraphBuilder)1 ImmutableGraph (com.google.common.graph.ImmutableGraph)1 MutableGraph (com.google.common.graph.MutableGraph)1 ArrayList (java.util.ArrayList)1