Search in sources :

Example 1 with TableMapping

use of org.forgerock.audit.handlers.jdbc.TableMapping in project OpenAM by OpenRock.

the class JdbcAuditEventHandlerFactory method getTableMapping.

private TableMapping getTableMapping(String eventTopic, Map<String, Set<String>> attributes) {
    TableMapping tableMapping = new TableMapping();
    tableMapping.setEvent(eventTopic);
    String tableName = getMapAttr(attributes, eventTopic + "EventTable");
    if (isEmpty(tableName)) {
        tableName = "am_audit" + eventTopic;
    }
    tableMapping.setTable(tableName);
    Set<String> fieldToColumnSet = attributes.get(eventTopic + "EventColumns");
    if (isEmpty(fieldToColumnSet)) {
        fieldToColumnSet = JdbcFieldToColumnDefaultValues.getDefaultValues(eventTopic);
    }
    tableMapping.setFieldToColumn(MAP_VALUE_PARSER.parse(fieldToColumnSet));
    return tableMapping;
}
Also used : TableMapping(org.forgerock.audit.handlers.jdbc.TableMapping)

Example 2 with TableMapping

use of org.forgerock.audit.handlers.jdbc.TableMapping in project OpenAM by OpenRock.

the class JdbcAuditEventHandlerFactory method create.

@Override
public AuditEventHandler create(AuditEventHandlerConfiguration configuration) throws AuditException {
    Map<String, Set<String>> attributes = configuration.getAttributes();
    JdbcAuditEventHandlerConfiguration handlerConfig = new JdbcAuditEventHandlerConfiguration();
    handlerConfig.setTopics(attributes.get("topics"));
    handlerConfig.setName(configuration.getHandlerName());
    handlerConfig.setEnabled(getBooleanMapAttr(attributes, "enabled", false));
    handlerConfig.setDatabaseType(getMapAttr(attributes, "databaseType"));
    List<TableMapping> tableMappings = new ArrayList<>();
    tableMappings.add(getTableMapping(AUTHENTICATION_TOPIC, attributes));
    tableMappings.add(getTableMapping(ACTIVITY_TOPIC, attributes));
    tableMappings.add(getTableMapping(ACCESS_TOPIC, attributes));
    tableMappings.add(getTableMapping(CONFIG_TOPIC, attributes));
    handlerConfig.setTableMappings(tableMappings);
    handlerConfig.setBufferingConfiguration(getBufferingConfiguration(attributes));
    return new JdbcAuditEventHandler(handlerConfig, configuration.getEventTopicsMetaData(), getDataSource(attributes));
}
Also used : Set(java.util.Set) JdbcAuditEventHandler(org.forgerock.audit.handlers.jdbc.JdbcAuditEventHandler) ArrayList(java.util.ArrayList) JdbcAuditEventHandlerConfiguration(org.forgerock.audit.handlers.jdbc.JdbcAuditEventHandlerConfiguration) TableMapping(org.forgerock.audit.handlers.jdbc.TableMapping)

Aggregations

TableMapping (org.forgerock.audit.handlers.jdbc.TableMapping)2 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 JdbcAuditEventHandler (org.forgerock.audit.handlers.jdbc.JdbcAuditEventHandler)1 JdbcAuditEventHandlerConfiguration (org.forgerock.audit.handlers.jdbc.JdbcAuditEventHandlerConfiguration)1