Search in sources :

Example 1 with AuditServiceFactory

use of com.evolveum.midpoint.audit.api.AuditServiceFactory in project midpoint by Evolveum.

the class AuditFactory method init.

public void init() {
    Configuration config = getCurrentConfiguration();
    //TODO FIX CONFIGURATION, CLEANUP REALLY NEEDED
    List<SubnodeConfiguration> auditServices = ((XMLConfiguration) ((CompositeConfiguration) ((SubsetConfiguration) config).getParent()).getConfiguration(0)).configurationsAt(AUDIT_CONFIGURATION + "." + CONF_AUDIT_SERVICE);
    for (SubnodeConfiguration serviceConfig : auditServices) {
        try {
            String factoryClass = getFactoryClassName(serviceConfig);
            Class<AuditServiceFactory> clazz = (Class<AuditServiceFactory>) Class.forName(factoryClass);
            AuditServiceFactory factory = getFactory(clazz);
            factory.init(serviceConfig);
            serviceFactories.add(factory);
        } catch (Exception ex) {
            LoggingUtils.logException(LOGGER, "AuditServiceFactory implementation class {} failed to " + "initialize.", ex, getFactoryClassName(serviceConfig));
            throw new SystemException("AuditServiceFactory implementation class " + getFactoryClassName(serviceConfig) + " failed to initialize: " + ex.getMessage(), ex);
        }
    }
}
Also used : MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) RuntimeConfiguration(com.evolveum.midpoint.common.configuration.api.RuntimeConfiguration) SystemException(com.evolveum.midpoint.util.exception.SystemException) AuditServiceFactory(com.evolveum.midpoint.audit.api.AuditServiceFactory) BeansException(org.springframework.beans.BeansException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 2 with AuditServiceFactory

use of com.evolveum.midpoint.audit.api.AuditServiceFactory in project midpoint by Evolveum.

the class AuditFactory method getAuditService.

public AuditService getAuditService() {
    if (auditService == null) {
        AuditServiceProxy proxy = new AuditServiceProxy();
        for (AuditServiceFactory factory : serviceFactories) {
            try {
                AuditService service = factory.getAuditService();
                //todo check this autowiring (check logs) how it's done
                applicationContext.getAutowireCapableBeanFactory().autowireBean(service);
                proxy.registerService(service);
            } catch (Exception ex) {
                LoggingUtils.logException(LOGGER, "Couldn't get audit service from factory '{}'", ex, factory);
                throw new SystemException(ex.getMessage(), ex);
            }
        }
        auditService = proxy;
    }
    return auditService;
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) AuditServiceFactory(com.evolveum.midpoint.audit.api.AuditServiceFactory) AuditService(com.evolveum.midpoint.audit.api.AuditService) BeansException(org.springframework.beans.BeansException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Aggregations

AuditServiceFactory (com.evolveum.midpoint.audit.api.AuditServiceFactory)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 BeansException (org.springframework.beans.BeansException)2 AuditService (com.evolveum.midpoint.audit.api.AuditService)1 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)1 RuntimeConfiguration (com.evolveum.midpoint.common.configuration.api.RuntimeConfiguration)1