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 theAuditBackend
interface using MongoDB persistence.- Since:
- 9.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MongoDBAuditBackend.MongoDBLogEntryProvider
-
Field Summary
Fields Modifier and Type Field Description static String
AUDIT_DATABASE_ID
protected com.mongodb.client.MongoCollection<org.bson.Document>
collection
static String
COLLECTION_NAME_PROPERTY
protected CursorService<com.mongodb.client.MongoCursor<org.bson.Document>,org.bson.Document,String>
cursorService
static String
DEFAULT_COLLECTION_NAME
static com.fasterxml.jackson.databind.ObjectMapper
OBJECT_MAPPER
protected MongoDBAuditBackend.MongoDBLogEntryProvider
provider
static String
SEQ_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 void
addLogEntries(List<LogEntry> entries)
Adds given log entries.void
append(List<String> jsonEntries)
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)
String
expandQueryVariables(String query, Object[] params)
String
expandQueryVariables(String query, Map<String,Object> params)
int
getApplicationStartedOrder()
com.mongodb.client.MongoCollection<org.bson.Document>
getAuditCollection()
Long
getEventsCount(String eventId)
LogEntry
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.ExtendedInfo
newExtendedInfo(Serializable value)
Create a new ExtendedInfo instancevoid
onApplicationStarted()
void
onApplicationStopped()
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)
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, 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:
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
public List<LogEntry> queryLogs(QueryBuilder builder)
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
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: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
public List<?> nativeQuery(String query, Map<String,Object> params, int pageNb, int pageSize)
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
-
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
public void addLogEntries(List<LogEntry> entries)
Description copied from interface:AuditLogger
Adds given log entries.- Specified by:
addLogEntries
in interfaceAuditLogger
- Parameters:
entries
- the list of log entries.
-
getEventsCount
public Long getEventsCount(String eventId)
- Specified by:
getEventsCount
in interfaceAuditAdmin
-
syncLogCreationEntries
public long syncLogCreationEntries(String repoId, String path, Boolean recurs)
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
public ExtendedInfo newExtendedInfo(Serializable value)
Description copied from interface:AuditLogger
Create a new ExtendedInfo instance- Specified by:
newExtendedInfo
in interfaceAuditLogger
- Specified by:
newExtendedInfo
in classAbstractAuditBackend
-
append
public void append(List<String> jsonEntries)
- Specified by:
append
in interfaceAuditStorage
-
scroll
public ScrollResult<String> scroll(QueryBuilder builder, int batchSize, int keepAliveSeconds)
- Specified by:
scroll
in interfaceAuditStorage
-
scroll
public ScrollResult<String> scroll(String scrollId)
- Specified by:
scroll
in interfaceAuditStorage
-
-