use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class EventDefinitionFacade method resolveForInstallationV1.
private Graph<Entity> resolveForInstallationV1(EntityV1 entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Entity> entities) {
final MutableGraph<Entity> graph = GraphBuilder.directed().build();
graph.addNode(entity);
final EventDefinitionEntity eventDefinition = objectMapper.convertValue(entity.data(), EventDefinitionEntity.class);
eventDefinition.resolveForInstallation(entity, parameters, entities, graph);
return ImmutableGraph.copyOf(graph);
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class EventDefinitionFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Optional<EventDefinitionDto> eventDefinition = eventDefinitionService.get(modelId.id());
if (!eventDefinition.isPresent()) {
LOG.debug("Couldn't find event definition {}", entityDescriptor);
return Optional.empty();
}
return Optional.of(exportNativeEntity(eventDefinition.get(), entityDescriptorIds));
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class EventNotificationHandlerConfigEntity method toNativeEntity.
@Override
public EventNotificationHandler.Config toNativeEntity(Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> natvieEntities) {
String notificationId = notificationId().asString(parameters);
final EntityDescriptor notificationDescriptor = EntityDescriptor.create(notificationId, ModelTypes.NOTIFICATION_V1);
final Object notification = natvieEntities.get(notificationDescriptor);
final EventNotificationHandler.Config.Builder configBuilder = EventNotificationHandler.Config.builder();
if (notification == null) {
throw new ContentPackException("Missing notification (" + notificationId + ") for event definition");
} else if (notification instanceof NotificationDto) {
NotificationDto notificationDto = (NotificationDto) notification;
configBuilder.notificationId(notificationDto.id());
} else {
throw new ContentPackException("Invalid type for notification (" + notificationId + ") of event definition: " + notification.getClass());
}
return configBuilder.notificationParameters(notificationParameters().orElse(null)).build();
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class NotificationFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Optional<NotificationDto> notificationDto = notificationService.get(modelId.id());
if (!notificationDto.isPresent()) {
LOG.debug("Couldn't find notification {}", entityDescriptor);
return Optional.empty();
}
final NotificationEntity entity = (NotificationEntity) notificationDto.get().toContentPackEntity(entityDescriptorIds);
final JsonNode data = objectMapper.convertValue(entity, JsonNode.class);
return Optional.of(EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(notificationDto.get().id(), ModelTypes.NOTIFICATION_V1))).type(ModelTypes.NOTIFICATION_V1).data(data).build());
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class InputFacade method resolveForInstallationV1.
private Graph<Entity> resolveForInstallationV1(EntityV1 entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Entity> entities) {
final MutableGraph<Entity> graph = GraphBuilder.directed().build();
graph.addNode(entity);
final InputEntity input = objectMapper.convertValue(entity.data(), InputEntity.class);
resolveForInstallationV1LookupTable(entity, input, parameters, entities, graph);
resolveForInstallationV1GrokPattern(entity, input, parameters, entities, graph);
return ImmutableGraph.copyOf(graph);
}
Aggregations