Package org.forgerock.audit.events
Class ConfigAuditEventBuilder<T extends ConfigAuditEventBuilder<T>>
- java.lang.Object
-
- org.forgerock.audit.events.AuditEventBuilder<T>
-
- org.forgerock.audit.events.ConfigAuditEventBuilder<T>
-
- Type Parameters:
T
- the type of the builder
public class ConfigAuditEventBuilder<T extends ConfigAuditEventBuilder<T>> extends AuditEventBuilder<T>
Builder for audit config events.This builder should not be used directly but be specialized for each product to allow to define new specific fields, e.g
class OpenProductConfigAuditEventBuilder<T extends OpenProductConfigAuditEventBuilder<T>> extends ConfigAuditEventBuilder<T> { public static <T> OpenProductConfigAuditEventBuilder<?> productConfigEvent() { return new OpenProductConfigAuditEventBuilder(); } public T someField(String v) { jsonValue.put("someField", v); return self(); } ... }
-
-
Field Summary
Fields Modifier and Type Field Description static String
AFTER
static String
BEFORE
static String
CHANGED_FIELDS
static String
OBJECT_ID
static String
OPERATION
static String
REVISION
static String
RUN_AS
-
Fields inherited from class org.forgerock.audit.events.AuditEventBuilder
EVENT_NAME, ISO_OFFSET_DATE_TIME_FORMAT, jsonValue, TIMESTAMP, TRACKING_IDS, TRANSACTION_ID, USER_ID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConfigAuditEventBuilder()
Creates the builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
after(String state)
Records the new state of the modified object as a String.T
after(JsonValue state)
Records the new state of the modified object as JSON.T
before(String state)
Records the previous state of the modified object as a String.T
before(JsonValue state)
Records the previous state of the modified object as JSON.T
changedFields(String... fieldNames)
Sets the list of fields that were changed by this update.static ConfigAuditEventBuilder<?>
configEvent()
Starts to build an audit config event.T
objectId(String objectId)
Sets the provided objectId for the event.T
objectIdFromCrestRequest(Request request)
Sets objectId method fromRequest
.T
operation(String operation)
Sets the provided operation for the event.T
operationFromCrestRequest(Request request)
Sets operation method fromRequest
.T
revision(String newRevision)
Sets the revision for the event.T
runAs(String id)
Sets the provided runAs for the event.protected void
setDefaults()
Called byAuditEventBuilder.toEvent()
to allow any unset fields to be given their default value.protected void
validate()
Called byAuditEventBuilder.toEvent()
to ensure that the audit event will be created in a valid state.-
Methods inherited from class org.forgerock.audit.events.AuditEventBuilder
eventName, requireField, self, timestamp, toEvent, trackingId, trackingIds, transactionId, transactionIdFromContext, userId
-
-
-
-
Field Detail
-
RUN_AS
public static final String RUN_AS
- See Also:
- Constant Field Values
-
OBJECT_ID
public static final String OBJECT_ID
- See Also:
- Constant Field Values
-
OPERATION
public static final String OPERATION
- See Also:
- Constant Field Values
-
BEFORE
public static final String BEFORE
- See Also:
- Constant Field Values
-
AFTER
public static final String AFTER
- See Also:
- Constant Field Values
-
REVISION
public static final String REVISION
- See Also:
- Constant Field Values
-
CHANGED_FIELDS
public static final String CHANGED_FIELDS
- See Also:
- Constant Field Values
-
-
Method Detail
-
configEvent
public static ConfigAuditEventBuilder<?> configEvent()
Starts to build an audit config event.Note: it is preferable to use a specialized builder that allow to add fields specific to a product.
- Returns:
- an audit config event builder
-
setDefaults
protected void setDefaults()
Called byAuditEventBuilder.toEvent()
to allow any unset fields to be given their default value. When overriding this method, the super class implementation must be called.- Overrides:
setDefaults
in classAuditEventBuilder<T extends org.forgerock.audit.events.StateChangeAuditEventBuilder<T>>
-
validate
protected void validate()
Called byAuditEventBuilder.toEvent()
to ensure that the audit event will be created in a valid state. When overriding this method, the super class implementation must be called.- Overrides:
validate
in classAuditEventBuilder<T extends org.forgerock.audit.events.StateChangeAuditEventBuilder<T>>
-
runAs
public final T runAs(String id)
Sets the provided runAs for the event.- Parameters:
id
- the id of user this operation was performed as.- Returns:
- this builder
-
objectId
public final T objectId(String objectId)
Sets the provided objectId for the event.- Parameters:
objectId
- the resource identifier.- Returns:
- this builder
-
operation
public final T operation(String operation)
Sets the provided operation for the event.- Parameters:
operation
- the type of operation (e.g. CREATE, READ, UPDATE, DELETE, PATCH, QUERY, or the ACTION name).- Returns:
- this builder
-
before
public final T before(String state)
Records the previous state of the modified object as a String.- Parameters:
state
- A String representation of the object's previous state.- Returns:
- this builder
-
before
public final T before(JsonValue state)
Records the previous state of the modified object as JSON.- Parameters:
state
- A JSON representation of the object's previous state.- Returns:
- this builder
-
after
public final T after(String state)
Records the new state of the modified object as a String.- Parameters:
state
- A String representation of the object's new state.- Returns:
- this builder
-
after
public final T after(JsonValue state)
Records the new state of the modified object as JSON.- Parameters:
state
- A JSON representation of the object's new state.- Returns:
- this builder
-
revision
public final T revision(String newRevision)
Sets the revision for the event.- Parameters:
newRevision
- resulting revision of the affected object.- Returns:
- this builder
-
changedFields
public final T changedFields(String... fieldNames)
Sets the list of fields that were changed by this update.- Parameters:
fieldNames
- of the object that were updated.- Returns:
- this builder
-
objectIdFromCrestRequest
public final T objectIdFromCrestRequest(Request request)
Sets objectId method fromRequest
.- Parameters:
request
- The CREST request.- Returns:
- this builder
-
-