Package org.nuxeo.audit.mongodb
Class MongoDBAuditBackend
java.lang.Object
org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend<LogEntry>
org.nuxeo.audit.service.AbstractAuditBackend
org.nuxeo.audit.mongodb.MongoDBAuditBackend
- All Implemented Interfaces:
AuditBackend,AuditBackend.CursorServiceScroll<com.mongodb.client.MongoCursor<org.bson.Document>,,org.bson.Document> AuditAdmin,AuditLogger<LogEntry>,AuditReader<LogEntry>,AuditStorage,Logs<LogEntry>,AuditBackend<LogEntry>
public class MongoDBAuditBackend
extends AbstractAuditBackend
implements AuditBackend.CursorServiceScroll<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document>
Implementation of the
AuditBackend interface using MongoDB persistence.- Since:
- 9.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.audit.service.AuditBackend
AuditBackend.Capability, AuditBackend.CursorServiceScroll<C,O> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.mongodb.client.MongoCollection<org.bson.Document> protected final CursorService<com.mongodb.client.MongoCursor<org.bson.Document>, org.bson.Document, String> static final Stringprotected final CursorService<com.mongodb.client.MongoCursor<org.bson.Document>, org.bson.Document, String> Fields inherited from class org.nuxeo.audit.service.AbstractAuditBackend
nameFields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET -
Constructor Summary
ConstructorsConstructorDescriptionMongoDBAuditBackend(com.mongodb.client.MongoCollection<org.bson.Document> collection) -
Method Summary
Modifier and TypeMethodDescriptionvoidorg.bson.conversions.BsonbuildFilter(String query, Map<String, Object> params) protected voidINTERNAL METHOD FOR TESTS, DO NOT USE.expandQueryVariables(String query, Object[] params) expandQueryVariables(String query, Map<String, Object> params) com.mongodb.client.MongoCollection<org.bson.Document> CursorService<com.mongodb.client.MongoCursor<org.bson.Document>, org.bson.Document, String> getEventsCount(String eventId) getLogEntryByID(long id) Returns a given log entry given its id.booleanhasCapability(AuditBackend.Capability capability) Checks whether the backend has the capability.protected static voidinitUIDSequencer(com.mongodb.client.MongoCollection<org.bson.Document> collection) Ensures the audit sequence returns an UID greater or equal than the maximum log entry id.voidinsertLogs(Collection<LogEntry> entries) Inserts the given log entries into the backend.List<?> nativeQuery(String query, Map<String, Object> params, int pageNb, int pageSize) Returns a batched list of entries.queryLogs(QueryBuilder query) Returns the logs given a collection of predicates and a default sort.scroll(QueryBuilder query, int batchSize, int keepAliveSeconds) CursorResult<com.mongodb.client.MongoCursor<org.bson.Document>, org.bson.Document> scrollLogIdsAsCursor(QueryBuilder query, int batchSize, Duration keepAlive) Methods inherited from class org.nuxeo.audit.service.AbstractAuditBackend
addLogEntries, doCreateAndFillEntryFromDocument, getApplicationStartedOrder, newExtendedInfo, onApplicationStarted, onApplicationStopped, setName, syncLogCreationEntriesMethods inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
await, buildEntryFromEvent, doPutExtendedInfos, doSyncNode, getAuditableEventNames, guardedDocument, guardedDocumentChildren, isAuditable, newLogEntry, populateExtendedInfo, restore, syncLogCreationEntriesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditAdmin
syncLogCreationEntriesMethods inherited from interface org.nuxeo.audit.service.AuditBackend
addLogEntries, getLatestLogId, getLogEntriesForMethods inherited from interface org.nuxeo.ecm.platform.audit.service.AuditBackend
getApplicationStartedOrder, onApplicationStarted, onApplicationStopped, restoreMethods inherited from interface org.nuxeo.audit.service.AuditBackend.CursorServiceScroll
clearScrollLogIds, scrollLogIds, scrollLogIdsMethods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditLogger
await, buildEntryFromEvent, getAuditableEventNames, newExtendedInfo, newLogEntryMethods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditReader
getLogEntriesAfter, nativeQuery, nativeQueryLogs, queryLogs, queryLogsByPage, queryLogsByPage, queryLogsByPage, queryLogsByPage
-
Field Details
-
SEQ_NAME
- See Also:
-
collection
protected final com.mongodb.client.MongoCollection<org.bson.Document> collection -
cursorService
protected final CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document, cursorServiceString> -
storageCursorService
protected final CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document, storageCursorServiceString>
-
-
Constructor Details
-
MongoDBAuditBackend
public MongoDBAuditBackend(com.mongodb.client.MongoCollection<org.bson.Document> collection) - Since:
- 2025.0
-
-
Method Details
-
getAuditCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getAuditCollection()- Returns:
- the
MongoCollectionconfigured with audit settings.
-
initUIDSequencer
protected static void initUIDSequencer(com.mongodb.client.MongoCollection<org.bson.Document> collection) Ensures the audit sequence returns an UID greater or equal than the maximum log entry id. -
queryLogs
Description copied from interface:AuditBackendReturns the logs given a collection of predicates and a default sort.- Specified by:
queryLogsin interfaceAuditBackend- Specified by:
queryLogsin interfaceAuditReader<LogEntry>- Parameters:
query- the query builder to fetch log entries- Returns:
- a list of log entries
-
scrollLogIdsAsCursor
public CursorResult<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document> scrollLogIdsAsCursor(QueryBuilder query, int batchSize, Duration keepAlive) - Specified by:
scrollLogIdsAsCursorin interfaceAuditBackend.CursorServiceScroll<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document> - Since:
- 2025.18
-
getLogEntryByID
Description copied from interface:AuditBackendReturns a given log entry given its id.- Specified by:
getLogEntryByIDin interfaceAuditBackend- Specified by:
getLogEntryByIDin interfaceAuditReader<LogEntry>- Parameters:
id- the log entry identifier- Returns:
- a LogEntry instance
-
nativeQuery
Description copied from interface:AuditReaderReturns a batched list of entries.- Specified by:
nativeQueryin interfaceAuditReader<LogEntry>- Parameters:
query- a JPA query language query if implementation of audit backend is JPA (< 7.3 or audit.elasticsearch.enabled=false) and JSON if implementation is Elasticsearchparams- parameters for the querypageNb- the page number (starts at 1)pageSize- the number of results per page
-
buildFilter
-
expandQueryVariables
-
expandQueryVariables
-
insertLogs
Description copied from interface:AuditBackendInserts the given log entries into the backend.- Specified by:
insertLogsin interfaceAuditBackend- Parameters:
entries- the list of log entries
-
getEventsCount
- Specified by:
getEventsCountin interfaceAuditAdmin- Specified by:
getEventsCountin interfaceAuditBackend
-
append
- Specified by:
appendin interfaceAuditStorage- Overrides:
appendin classAbstractAuditBackend
-
scroll
- Specified by:
scrollin interfaceAuditStorage- Overrides:
scrollin classAbstractAuditBackend
-
scroll
- Specified by:
scrollin interfaceAuditStorage- Overrides:
scrollin classAbstractAuditBackend
-
clearEntries
protected void clearEntries()Description copied from class:AbstractAuditBackendINTERNAL METHOD FOR TESTS, DO NOT USE.- Overrides:
clearEntriesin classAbstractAuditBackend
-
hasCapability
Description copied from interface:AuditBackendChecks whether the backend has the capability.- Specified by:
hasCapabilityin interfaceAuditBackend
-
getCursorService
public CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document, getCursorService()String> - Specified by:
getCursorServicein interfaceAuditBackend.CursorServiceScroll<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document> - Returns:
- the
CursorServiceto use when scrolling elements, the service must be a singleton
-