1 /* 2 * The contents of this file are subject to the terms of the Common Development and 3 * Distribution License (the License). You may not use this file except in compliance with the 4 * License. 5 * 6 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 7 * specific language governing permission and limitations under the License. 8 * 9 * When distributing Covered Software, include this CDDL Header Notice in each file and include 10 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 11 * Header, with the fields enclosed by brackets [] replaced by your own identifying 12 * information: "Portions copyright [year] [name of copyright owner]". 13 * 14 * Copyright 2015 ForgeRock AS. 15 */ 16 package org.forgerock.audit.handlers.jdbc; 17 18 import org.forgerock.audit.AuditException; 19 import org.forgerock.json.JsonValue; 20 import org.forgerock.json.resource.QueryRequest; 21 22 /** 23 * Provides Create, Read, and Query events for the implementing database. 24 */ 25 interface DatabaseStatementProvider { 26 27 /** 28 * Builds a {@link JdbcAuditEvent} that can be used to create a prepared statement to create an event. 29 * @param content The content of the audit event. 30 * @param tableMapping The TableMapping of json fields to table columns. 31 * @return A {@link JdbcAuditEvent}. 32 * @throws AuditException If unable to create the {@link JdbcAuditEvent}. 33 */ 34 JdbcAuditEvent buildCreateEvent(JsonValue content, TableMapping tableMapping, 35 JsonValue eventTopicMetaData) throws AuditException; 36 37 /** 38 * Builds a {@link JdbcAuditEvent} that can be used to create a prepared statement to read an event. 39 * @param mapping The TableMapping of json fields to table columns. 40 * @param id The id of the object to read. 41 * @return A {@link JdbcAuditEvent}. 42 * @throws AuditException If unable to create the {@link JdbcAuditEvent}. 43 */ 44 JdbcAuditEvent buildReadEvent(TableMapping mapping, String id, JsonValue eventTopicMetaData) 45 throws AuditException; 46 47 /** 48 * Builds a {@link JdbcAuditEvent} that can be used to create a prepared statement to query an event. 49 * @param mapping The TableMapping of json fields to table columns. 50 * @param queryRequest The QueryRequest sent to the audit event handler. 51 * @return A {@link JdbcAuditEvent}. 52 * @throws AuditException If unable to create the {@link JdbcAuditEvent}. 53 */ 54 JdbcAuditEvent buildQueryEvent(TableMapping mapping, QueryRequest queryRequest, 55 JsonValue eventTopicMetaData) throws AuditException; 56 }