Owns audit trail lookups and record restoration for the current tenant. Every create, update or delete on an Auditable entity is recorded as an AuditItem; this manager finds those items, decodes the state they captured and can restore an entity to a previously audited state. Reached from JS as the registered auditManager service.

Group: Managers


Methods

newAuditItemSearchBuilder()

Returns: AuditItemSearchBuilder

Create a new AuditItemSearchBuilder for searching audit items in the current tenant org.

parseRecordState(AuditItem ai)

Returns: Map<String,Object>

Decodes the recordState XML captured on an audit item back into a map of property name to value, as it was at the point the item was recorded.

ParameterDescription
aithe audit item to decode, may be null

findPrevious(AuditItem ai)

Returns: AuditItem

Finds the audit item most recently recorded before the given one, for the same entity.

ParameterDescription
aithe audit item to search before

findNext(AuditItem ai)

Returns: AuditItem

Finds the audit item recorded soonest after the given one, for the same entity. An update's recordState is the snapshot before that change, so the next item's snapshot is the state after it.

ParameterDescription
aithe audit item to search after

parseCurrentState(AuditItem ai)

Returns: Map<String,Object>

Builds the same property map an audit item would capture, but from the entity as it is now. Used as the state after the most recent change, which has no later audit item to compare against.

ParameterDescription
aian audit item identifying the entity

restoreAuditItem(AuditItem ai)

Returns: void

Reverts an entity to the state captured by the given audit item: a CREATE is undone by deleting the record, an UPDATE or DELETE is undone by restoring the recorded field values (recreating the entity first if it no longer exists). Also records the current user and time as the revert details on the audit item and re-indexes the affected entity for search.

ParameterDescription
aithe audit item describing the change to revert

findChangeType(String value)

Returns: ChangeType

Parses a change type name into its AuditItem.ChangeType value, case insensitively.

ParameterDescription
valuethe change type name, e.g. "create", "update" or "delete"

findByUserNameOrEmailRecursive(String nameOrEmail)

Returns: Profile

Finds a profile by username or email within the current tenant organisation, searching recursively down through its sub-organisations.

ParameterDescription
nameOrEmailthe username or email address to look up
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.