use of io.gravitee.am.reporter.api.provider.NoOpReporter in project gravitee-access-management by gravitee-io.
the class AuditReporterManagerImpl method doStart.
@Override
protected void doStart() throws Exception {
super.doStart();
logger.info("Register event listener for reporter events for the management API");
eventManager.subscribeForEvents(this, ReporterEvent.class);
// init noOpReporter
noOpReporter = new NoOpReporter();
// init internal reporter (organization reporter)
NewReporter organizationReporter = reporterService.createInternal();
logger.info("Initializing internal " + organizationReporter.getType() + " audit reporter");
internalReporter = reporterPluginManager.create(organizationReporter.getType(), organizationReporter.getConfiguration(), null);
logger.info("Internal audit " + organizationReporter.getType() + " reporter initialized");
logger.info("Initializing audit reporters");
reporterService.findAll().blockingForEach(reporter -> {
logger.info("Initializing audit reporter : {} for domain {}", reporter.getName(), reporter.getDomain());
try {
AuditReporterLauncher launcher = new AuditReporterLauncher(reporter);
domainService.findById(reporter.getDomain()).flatMapSingle(domain -> {
if (ReferenceType.ENVIRONMENT.equals(domain.getReferenceType())) {
return environmentService.findById(domain.getReferenceId()).map(env -> new GraviteeContext(env.getOrganizationId(), env.getId(), domain.getId()));
} else {
// currently domain is only linked to domainEnv
return Single.error(new EnvironmentNotFoundException("Domain " + reporter.getDomain() + " should be lined to an Environment"));
}
}).subscribeOn(Schedulers.io()).subscribe(launcher);
} catch (Exception ex) {
logger.error("An error has occurred while loading audit reporter: {} [{}]", reporter.getName(), reporter.getType(), ex);
removeReporter(reporter.getId());
}
});
// deploy internal reporter verticle
deployReporterVerticle(asList(new EventBusReporterWrapper(vertx, internalReporter)));
}
Aggregations