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
public class MongoDBAuditBackend extends AbstractAuditBackend implements AuditBackend
Implementation of theAuditBackendinterface using MongoDB persistence.- Since:
- 9.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMongoDBAuditBackend.MongoDBLogEntryProvider
-
Field Summary
Fields Modifier and Type Field Description static StringAUDIT_DATABASE_IDprotected com.mongodb.client.MongoCollection<org.bson.Document>collectionstatic StringCOLLECTION_NAME_PROPERTYprotected CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document,String>cursorServicestatic StringDEFAULT_COLLECTION_NAMEstatic com.fasterxml.jackson.databind.ObjectMapperOBJECT_MAPPERprotected MongoDBAuditBackend.MongoDBLogEntryProviderproviderstatic StringSEQ_NAME-
Fields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET
-
-
Constructor Summary
Constructors Constructor Description MongoDBAuditBackend()MongoDBAuditBackend(NXAuditEventsService component, AuditBackendDescriptor config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLogEntries(List<LogEntry> entries)Adds given log entries.voidappend(List<String> jsonEntries)org.bson.conversions.BsonbuildFilter(String query, Map<String,Object> params)protected org.bson.conversions.BsoncreateFilter(MultiExpression andPredicate)protected org.bson.conversions.BsoncreateSort(OrderByList orders)StringexpandQueryVariables(String query, Object[] params)StringexpandQueryVariables(String query, Map<String,Object> params)intgetApplicationStartedOrder()com.mongodb.client.MongoCollection<org.bson.Document>getAuditCollection()LonggetEventsCount(String eventId)LogEntrygetLogEntryByID(long id)Returns a given log entry given its id.protected StringgetMongoDBKey(String key)List<?>nativeQuery(String query, Map<String,Object> params, int pageNb, int pageSize)Returns a batched list of entries.ExtendedInfonewExtendedInfo(Serializable value)Create a new ExtendedInfo instancevoidonApplicationStarted()voidonApplicationStopped()List<LogEntry>queryLogs(QueryBuilder builder)Returns the logs given a collection of predicates and a default sort.List<LogEntry>queryLogsByPage(String[] eventIds, Date limit, String[] categories, String path, int pageNb, int pageSize)ScrollResult<String>scroll(String scrollId)ScrollResult<String>scroll(QueryBuilder builder, int batchSize, int keepAliveSeconds)longsyncLogCreationEntries(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, convert, doCreateAndFillEntryFromDocument, doPutExtendedInfos, doSyncNode, getAuditableEventNames, getLatestLogId, getLogEntriesAfter, getLogEntriesFor, 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
onShutdown, 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, getLogEntriesFor, getLogEntriesFor, nativeQuery, nativeQueryLogs, queryLogs, queryLogsByPage, queryLogsByPage, queryLogsByPage
-
-
-
-
Field Detail
-
AUDIT_DATABASE_ID
public static final String AUDIT_DATABASE_ID
- See Also:
- Constant Field Values
-
COLLECTION_NAME_PROPERTY
public static final String COLLECTION_NAME_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_COLLECTION_NAME
public static final String DEFAULT_COLLECTION_NAME
- See Also:
- Constant Field Values
-
SEQ_NAME
public static final String SEQ_NAME
- See Also:
- Constant Field Values
-
OBJECT_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
collection
protected com.mongodb.client.MongoCollection<org.bson.Document> collection
-
provider
protected MongoDBAuditBackend.MongoDBLogEntryProvider provider
-
cursorService
protected CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document,String> cursorService
-
-
Constructor Detail
-
MongoDBAuditBackend
public MongoDBAuditBackend(NXAuditEventsService component, AuditBackendDescriptor config)
-
MongoDBAuditBackend
public MongoDBAuditBackend()
- Since:
- 9.3
-
-
Method Detail
-
getApplicationStartedOrder
public int getApplicationStartedOrder()
- Specified by:
getApplicationStartedOrderin interfaceAuditBackend
-
onApplicationStarted
public void onApplicationStarted()
- Specified by:
onApplicationStartedin interfaceAuditBackend
-
onApplicationStopped
public void onApplicationStopped()
- Specified by:
onApplicationStoppedin interfaceAuditBackend
-
getAuditCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getAuditCollection()
- Returns:
- the
MongoCollectionconfigured with audit settings.
-
queryLogs
public List<LogEntry> queryLogs(QueryBuilder builder)
Description copied from interface:AuditReaderReturns the logs given a collection of predicates and a default sort.- Specified by:
queryLogsin interfaceAuditReader- Parameters:
builder- the query builder to fetch log entries- Returns:
- a list of log entries
-
createFilter
protected org.bson.conversions.Bson createFilter(MultiExpression andPredicate)
-
createSort
protected org.bson.conversions.Bson createSort(OrderByList orders)
-
getLogEntryByID
public LogEntry getLogEntryByID(long id)
Description copied from interface:AuditReaderReturns a given log entry given its id.- Specified by:
getLogEntryByIDin interfaceAuditReader- Parameters:
id- the log entry identifier- Returns:
- a LogEntry instance
-
nativeQuery
public List<?> nativeQuery(String query, Map<String,Object> params, int pageNb, int pageSize)
Description copied from interface:AuditReaderReturns a batched list of entries.- Specified by:
nativeQueryin 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
-
queryLogsByPage
public List<LogEntry> queryLogsByPage(String[] eventIds, Date limit, String[] categories, String path, int pageNb, int pageSize)
- Specified by:
queryLogsByPagein interfaceAuditReader- Overrides:
queryLogsByPagein classAbstractAuditBackend
-
addLogEntries
public void addLogEntries(List<LogEntry> entries)
Description copied from interface:AuditLoggerAdds given log entries.- Specified by:
addLogEntriesin interfaceAuditLogger- Parameters:
entries- the list of log entries.
-
getEventsCount
public Long getEventsCount(String eventId)
- Specified by:
getEventsCountin interfaceAuditAdmin
-
syncLogCreationEntries
public long syncLogCreationEntries(String repoId, String path, Boolean recurs)
Description copied from interface:AuditAdminForces 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:
syncLogCreationEntriesin interfaceAuditAdmin
-
newExtendedInfo
public ExtendedInfo newExtendedInfo(Serializable value)
Description copied from interface:AuditLoggerCreate a new ExtendedInfo instance- Specified by:
newExtendedInfoin interfaceAuditLogger- Specified by:
newExtendedInfoin classAbstractAuditBackend
-
append
public void append(List<String> jsonEntries)
- Specified by:
appendin interfaceAuditStorage
-
scroll
public ScrollResult<String> scroll(QueryBuilder builder, int batchSize, int keepAliveSeconds)
- Specified by:
scrollin interfaceAuditStorage
-
scroll
public ScrollResult<String> scroll(String scrollId)
- Specified by:
scrollin interfaceAuditStorage
-
-