Search in sources :

Example 1 with NoOpReporter

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)));
}
Also used : GraviteeContext(io.gravitee.am.common.utils.GraviteeContext) EnvironmentNotFoundException(io.gravitee.am.service.exception.EnvironmentNotFoundException) NoOpReporter(io.gravitee.am.reporter.api.provider.NoOpReporter) EventBusReporterWrapper(io.gravitee.am.service.reporter.vertx.EventBusReporterWrapper) NewReporter(io.gravitee.am.service.model.NewReporter) ReporterNotFoundForDomainException(io.gravitee.am.service.exception.ReporterNotFoundForDomainException) EnvironmentNotFoundException(io.gravitee.am.service.exception.EnvironmentNotFoundException)

Aggregations

GraviteeContext (io.gravitee.am.common.utils.GraviteeContext)1 NoOpReporter (io.gravitee.am.reporter.api.provider.NoOpReporter)1 EnvironmentNotFoundException (io.gravitee.am.service.exception.EnvironmentNotFoundException)1 ReporterNotFoundForDomainException (io.gravitee.am.service.exception.ReporterNotFoundForDomainException)1 NewReporter (io.gravitee.am.service.model.NewReporter)1 EventBusReporterWrapper (io.gravitee.am.service.reporter.vertx.EventBusReporterWrapper)1