use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class SidecarCollectorConfigurationFacade method decode.
private NativeEntity<Configuration> decode(EntityV1 entity, Map<String, ValueReference> parameters) {
final SidecarCollectorConfigurationEntity configurationEntity = objectMapper.convertValue(entity.data(), SidecarCollectorConfigurationEntity.class);
final Configuration configuration = Configuration.create(configurationEntity.collectorId().asString(parameters), configurationEntity.title().asString(parameters), configurationEntity.color().asString(parameters), configurationEntity.template().asString(parameters));
final Configuration savedConfiguration = configurationService.save(configuration);
return NativeEntity.create(entity.id(), savedConfiguration.id(), TYPE_V1, configuration.name(), savedConfiguration);
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class UrlWhitelistFacade method createNativeEntity.
@Override
public NativeEntity<WhitelistEntry> createNativeEntity(Entity entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> nativeEntities, String username) {
if (!(entity instanceof EntityV1)) {
throw new IllegalArgumentException("Unsupported entity version: " + entity.getClass());
}
final WhitelistEntry whitelistEntry = objectMapper.convertValue(((EntityV1) entity).data(), WhitelistEntry.class);
urlWhitelistService.addEntry(whitelistEntry);
return NativeEntity.create(entity.id(), whitelistEntry.id(), TYPE_V1, createTitle(whitelistEntry), whitelistEntry);
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class DashboardV1Facade method convertEntity.
private EntityV1 convertEntity(EntityV1 entityV1, Map<String, ValueReference> parameters) {
final DashboardEntity dashboardEntity = objectMapper.convertValue(entityV1.data(), DashboardEntity.class);
final ViewEntity viewEntity = entityConverter.convert(dashboardEntity, parameters);
final JsonNode data = objectMapper.convertValue(viewEntity, JsonNode.class);
return entityV1.toBuilder().data(data).type(ModelTypes.DASHBOARD_V2).build();
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class DashboardV1Facade method createNativeEntity.
@Override
public NativeEntity<ViewDTO> createNativeEntity(Entity entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> nativeEntities, String username) {
ensureV1(entity);
final User user = Optional.ofNullable(userService.load(username)).orElseThrow(() -> new IllegalStateException("Cannot load user <" + username + "> from db"));
return decode((EntityV1) entity, parameters, nativeEntities, user);
}
Aggregations