Class DefaultAuditBackend
- java.lang.Object
-
- org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
-
- org.nuxeo.ecm.platform.audit.service.DefaultAuditBackend
-
- All Implemented Interfaces:
AuditAdmin
,AuditLogger
,AuditReader
,AuditStorage
,Logs
,AuditBackend
public class DefaultAuditBackend extends AbstractAuditBackend
Contains the Hibernate based (legacy) implementation- Author:
- tiry
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DefaultAuditBackend.SQLAuditCursorResult
-
Field Summary
Fields Modifier and Type Field Description protected CursorService<Iterator<LogEntry>,LogEntry,String>
cursorService
protected static com.fasterxml.jackson.databind.ObjectMapper
OBJECT_MAPPER
protected PersistenceProvider
persistenceProvider
-
Fields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET, log
-
-
Constructor Summary
Constructors Constructor Description DefaultAuditBackend()
DefaultAuditBackend(NXAuditEventsService component, AuditBackendDescriptor config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
accept(boolean needActivateSession, Consumer<LogEntryProvider> consumer)
protected void
activatePersistenceProvider()
void
addLogEntries(List<LogEntry> entries)
Adds given log entries.void
append(List<String> jsonEntries)
protected <T> T
apply(boolean needActivateSession, Function<LogEntryProvider,T> function)
int
getApplicationStartedOrder()
Long
getEventsCount(String eventId)
long
getLatestLogId(String repositoryId, String... eventIds)
Returns the latest log id matching events and repository or 0 when no match found.List<LogEntry>
getLogEntriesAfter(long logIdOffset, int limit, String repositoryId, String... eventIds)
Returns up to limit log entries matching events and repository with log id greater or equal to logIdOffset.List<LogEntry>
getLogEntriesFor(String uuid)
Returns the logs given a doc uuid.List<LogEntry>
getLogEntriesFor(String uuid, String repositoryId)
Returns the logs given a doc uuid and a repository id.List<LogEntry>
getLogEntriesFor(String uuid, Map<String,FilterMapEntry> filterMap, boolean doDefaultSort)
Returns the logs given a doc uuid, a map of filters and a default sort.LogEntry
getLogEntryByID(long id)
Returns a given log entry given its id.List<String>
getLoggedEventIds()
PersistenceProvider
getOrCreatePersistenceProvider()
protected String
getParamNames(String[] eventId)
protected Map<String,Object>
getParams(String[] eventId)
List<?>
nativeQuery(String query, int pageNb, int pageSize)
Returns a batched list of entries.List<?>
nativeQuery(String query, Map<String,Object> params, int pageNb, int pageSize)
Returns a batched list of entries.List<LogEntry>
nativeQueryLogs(String whereClause, int pageNb, int pageSize)
Returns a batched list of log entries.ExtendedInfo
newExtendedInfo(Serializable value)
Create a new ExtendedInfo instancevoid
onApplicationStarted()
void
onApplicationStopped()
List<LogEntry>
queryLogs(String[] eventIds, String dateRange)
Returns the list of log entries.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[] category, 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, 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
-
Methods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditReader
queryLogsByPage, queryLogsByPage, queryLogsByPage
-
-
-
-
Field Detail
-
OBJECT_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
persistenceProvider
protected PersistenceProvider persistenceProvider
-
cursorService
protected CursorService<Iterator<LogEntry>,LogEntry,String> cursorService
-
-
Constructor Detail
-
DefaultAuditBackend
public DefaultAuditBackend(NXAuditEventsService component, AuditBackendDescriptor config)
-
DefaultAuditBackend
public DefaultAuditBackend()
- Since:
- 9.3
-
-
Method Detail
-
getApplicationStartedOrder
public int getApplicationStartedOrder()
-
onApplicationStarted
public void onApplicationStarted()
-
onApplicationStopped
public void onApplicationStopped()
-
getOrCreatePersistenceProvider
public PersistenceProvider getOrCreatePersistenceProvider()
-
activatePersistenceProvider
protected void activatePersistenceProvider()
-
apply
protected <T> T apply(boolean needActivateSession, Function<LogEntryProvider,T> function)
-
accept
protected void accept(boolean needActivateSession, Consumer<LogEntryProvider> consumer)
-
addLogEntries
public void addLogEntries(List<LogEntry> entries)
Description copied from interface:AuditLogger
Adds given log entries.- Parameters:
entries
- the list of log entries.
-
getLogEntriesFor
public List<LogEntry> getLogEntriesFor(String uuid, String repositoryId)
Description copied from interface:AuditReader
Returns the logs given a doc uuid and a repository id.- Parameters:
uuid
- the document uuidrepositoryId
- the repository id- Returns:
- a list of log entries
-
getLogEntriesFor
public List<LogEntry> getLogEntriesFor(String uuid)
Description copied from interface:AuditReader
Returns the logs given a doc uuid.- Parameters:
uuid
- the document uuid- Returns:
- a list of log entries
-
getLogEntriesFor
public List<LogEntry> getLogEntriesFor(String uuid, Map<String,FilterMapEntry> filterMap, boolean doDefaultSort)
Description copied from interface:AuditReader
Returns the logs given a doc uuid, a map of filters and a default sort.- Specified by:
getLogEntriesFor
in interfaceAuditReader
- Overrides:
getLogEntriesFor
in classAbstractAuditBackend
- Parameters:
uuid
- the document uuidfilterMap
- the map of filters to applydoDefaultSort
- the default sort to set (eventDate desc)- Returns:
- a list of log entries
-
getLogEntryByID
public LogEntry getLogEntryByID(long id)
Description copied from interface:AuditReader
Returns a given log entry given its id.- Parameters:
id
- the log entry identifier- Returns:
- a LogEntry instance
-
nativeQueryLogs
public List<LogEntry> nativeQueryLogs(String whereClause, int pageNb, int pageSize)
Description copied from interface:AuditReader
Returns a batched list of log entries. WhereClause is a native where clause for the backend: here EJBQL 3.0 must be used if implementation of audit backend is JPA (< 7.3 or audit.elasticsearch.enabled=false) and JSON if implementation is Elasticsearch.
-
nativeQuery
public List<?> nativeQuery(String query, int pageNb, int pageSize)
Description copied from interface:AuditReader
Returns a batched list of entries. query string is a native query clause for the backend : here EJBQL 3.0 must be used if implementation of audit backend is JPA (< 7.3 or audit.elasticsearch.enabled=false) and JSON if implementation is Elasticsearch.
-
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.- 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
-
queryLogs
public List<LogEntry> queryLogs(QueryBuilder builder)
Description copied from interface:AuditReader
Returns the logs given a collection of predicates and a default sort.- Parameters:
builder
- the query builder to fetch log entries- Returns:
- a list of log entries
-
queryLogs
public List<LogEntry> queryLogs(String[] eventIds, String dateRange)
Description copied from interface:AuditReader
Returns the list of log entries.Note we will use NXQL in the future when the search engine will index history.
- Parameters:
eventIds
- the event ids.dateRange
- a preset date range.- Returns:
- a list of log entries.
- See Also:
DateRangeQueryConstants
-
queryLogsByPage
public List<LogEntry> queryLogsByPage(String[] eventIds, Date limit, String[] category, String path, int pageNb, int pageSize)
- Specified by:
queryLogsByPage
in interfaceAuditReader
- Overrides:
queryLogsByPage
in classAbstractAuditBackend
-
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.
-
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
-
getLatestLogId
public long getLatestLogId(String repositoryId, String... eventIds)
Description copied from interface:AuditReader
Returns the latest log id matching events and repository or 0 when no match found.- Specified by:
getLatestLogId
in interfaceAuditReader
- Overrides:
getLatestLogId
in classAbstractAuditBackend
-
getLogEntriesAfter
public List<LogEntry> getLogEntriesAfter(long logIdOffset, int limit, String repositoryId, String... eventIds)
Description copied from interface:AuditReader
Returns up to limit log entries matching events and repository with log id greater or equal to logIdOffset.- Specified by:
getLogEntriesAfter
in interfaceAuditReader
- Overrides:
getLogEntriesAfter
in classAbstractAuditBackend
-
scroll
public ScrollResult<String> scroll(QueryBuilder builder, int batchSize, int keepAliveSeconds)
-
scroll
public ScrollResult<String> scroll(String scrollId)
-
-