Package org.nuxeo.mongodb.audit
Class MongoDBAuditBackend
java.lang.Object
org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
org.nuxeo.mongodb.audit.MongoDBAuditBackend
- All Implemented Interfaces:
AuditAdmin
,AuditLogger
,AuditReader
,AuditStorage
,Logs
,AuditBackend
Implementation of the
AuditBackend
interface using MongoDB persistence.- Since:
- 9.1
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected com.mongodb.client.MongoCollection<org.bson.Document>
static final String
protected CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,
org.bson.Document, String> static final String
static final com.fasterxml.jackson.databind.ObjectMapper
static final String
Fields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET
-
Constructor Summary
ConstructorDescriptionMongoDBAuditBackend
(NXAuditEventsService component, AuditBackendDescriptor config) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLogEntries
(List<LogEntry> entries) Adds given log entries.void
org.bson.conversions.Bson
buildFilter
(String query, Map<String, Object> params) protected org.bson.conversions.Bson
createFilter
(MultiExpression andPredicate) protected org.bson.conversions.Bson
createSort
(OrderByList orders) expandQueryVariables
(String query, Object[] params) expandQueryVariables
(String query, Map<String, Object> params) int
com.mongodb.client.MongoCollection<org.bson.Document>
getEventsCount
(String eventId) getLogEntryByID
(long id) Returns a given log entry given its id.protected String
getMongoDBKey
(String key) List<?>
nativeQuery
(String query, Map<String, Object> params, int pageNb, int pageSize) Returns a batched list of entries.newExtendedInfo
(Serializable value) Create a new ExtendedInfo instancevoid
void
queryLogs
(QueryBuilder builder) Returns the logs given a collection of predicates and a default sort.queryLogsByPage
(String[] eventIds, Date limit, String[] categories, String path, int pageNb, int pageSize) scroll
(QueryBuilder builder, int batchSize, int keepAliveSeconds) long
syncLogCreationEntries
(String repoId, String path, Boolean recurs) Forces log Synchronisation for a branch of the repository.Methods inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
await, buildEntryFromEvent, doCreateAndFillEntryFromDocument, doPutExtendedInfos, doSyncNode, getAuditableEventNames, getLatestLogId, getLogEntriesAfter, guardedDocument, guardedDocumentChildren, isAuditable, logEvent, logEvents, newLogEntry, populateExtendedInfo, restore, syncLogCreationEntries
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.ecm.platform.audit.service.AuditBackend
restore
Methods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditLogger
await, buildEntryFromEvent, getAuditableEventNames, logEvent, logEvents, newLogEntry
Methods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditReader
getLatestLogId, getLogEntriesAfter, getLogEntriesFor, nativeQuery, nativeQueryLogs, queryLogs, queryLogsByPage, queryLogsByPage, queryLogsByPage
-
Field Details
-
AUDIT_DATABASE_ID
- See Also:
-
COLLECTION_NAME_PROPERTY
- See Also:
-
DEFAULT_COLLECTION_NAME
- See Also:
-
SEQ_NAME
- See Also:
-
OBJECT_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER -
collection
protected com.mongodb.client.MongoCollection<org.bson.Document> collection -
provider
-
cursorService
protected CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document, cursorServiceString>
-
-
Constructor Details
-
MongoDBAuditBackend
-
MongoDBAuditBackend
public MongoDBAuditBackend()- Since:
- 9.3
-
-
Method Details
-
getApplicationStartedOrder
public int getApplicationStartedOrder()- Specified by:
getApplicationStartedOrder
in interfaceAuditBackend
-
onApplicationStarted
public void onApplicationStarted()- Specified by:
onApplicationStarted
in interfaceAuditBackend
-
onApplicationStopped
public void onApplicationStopped()- Specified by:
onApplicationStopped
in interfaceAuditBackend
-
getAuditCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getAuditCollection()- Returns:
- the
MongoCollection
configured with audit settings.
-
queryLogs
Description copied from interface:AuditReader
Returns the logs given a collection of predicates and a default sort.- Specified by:
queryLogs
in interfaceAuditReader
- Parameters:
builder
- the query builder to fetch log entries- Returns:
- a list of log entries
-
createFilter
-
createSort
-
getMongoDBKey
-
getLogEntryByID
Description copied from interface:AuditReader
Returns a given log entry given its id.- Specified by:
getLogEntryByID
in interfaceAuditReader
- Parameters:
id
- the log entry identifier- Returns:
- a LogEntry instance
-
nativeQuery
Description copied from interface:AuditReader
Returns a batched list of entries.- Specified by:
nativeQuery
in interfaceAuditReader
- 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
-
queryLogsByPage
public List<LogEntry> queryLogsByPage(String[] eventIds, Date limit, String[] categories, String path, int pageNb, int pageSize) - Specified by:
queryLogsByPage
in interfaceAuditReader
- Overrides:
queryLogsByPage
in classAbstractAuditBackend
-
addLogEntries
Description copied from interface:AuditLogger
Adds given log entries.- Specified by:
addLogEntries
in interfaceAuditLogger
- Parameters:
entries
- the list of log entries.
-
getEventsCount
- Specified by:
getEventsCount
in interfaceAuditAdmin
-
syncLogCreationEntries
Description copied from interface:AuditAdmin
Forces log Synchronisation for a branch of the repository. This can be useful to add the create entries if DB was initialized from a bulk import.- Specified by:
syncLogCreationEntries
in interfaceAuditAdmin
-
newExtendedInfo
Description copied from interface:AuditLogger
Create a new ExtendedInfo instance- Specified by:
newExtendedInfo
in interfaceAuditLogger
- Specified by:
newExtendedInfo
in classAbstractAuditBackend
-
append
- Specified by:
append
in interfaceAuditStorage
-
scroll
- Specified by:
scroll
in interfaceAuditStorage
-
scroll
- Specified by:
scroll
in interfaceAuditStorage
-