Package org.nuxeo.elasticsearch.audit
Class ESAuditBackend
java.lang.Object
org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
org.nuxeo.elasticsearch.audit.ESAuditBackend
- All Implemented Interfaces:
AuditAdmin
,AuditLogger
,AuditReader
,AuditStorage
,Logs
,AuditBackend
Implementation of the
AuditBackend
interface using Elasticsearch persistence- Author:
- tiry
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected CursorService<Iterator<org.opensearch.search.SearchHit>,
org.opensearch.search.SearchHit, String> protected ESClient
protected String
static final String
static final int
static final String
static final String
protected BaseLogEntryProvider
static final String
Fields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET
-
Constructor Summary
ConstructorDescriptionESAuditBackend
(NXAuditEventsService component, AuditBackendDescriptor config) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLogEntries
(List<LogEntry> entries) Adds given log entries.void
protected org.opensearch.index.query.QueryBuilder
buildFilter
(PredicateDefinition[] predicates, DocumentModel searchDocumentModel) buildLogEntries
(org.opensearch.action.search.SearchResponse searchResponse) org.opensearch.action.search.SearchRequest
buildQuery
(String query, Map<String, Object> params) org.opensearch.action.search.SearchRequest
buildSearchQuery
(String fixedPart, PredicateDefinition[] predicates, DocumentModel searchDocumentModel) protected Object
protected org.opensearch.index.query.QueryBuilder
createQueryBuilder
(MultiExpression andPredicate) protected org.opensearch.action.search.SearchRequest
protected org.opensearch.search.builder.SearchSourceBuilder
createSearchRequestSource
(MultiExpression predicate, OrderByList orders) protected org.opensearch.search.builder.SearchSourceBuilder
createSearchSourceBuilder
(String query) protected void
ensureUIDSequencer
(ESClient esClient) Ensures the audit sequence returns an UID greater or equal than the maximum log entry id.expandQueryVariables
(String query, Object[] params) expandQueryVariables
(String query, Map<String, Object> params) int
protected ESClient
protected String
getEventsCount
(String eventId) long
getLatestLogId
(String repositoryId, String... eventIds) Returns the latest log id matching events and repository or 0 when no match found.protected String
getLogEntryByID
(long id) Returns a given log entry given its id.protected boolean
protected boolean
isNonNullParam
(Object[] val) protected void
logSearchRequest
(org.opensearch.action.search.SearchRequest request) protected void
logSearchResponse
(org.opensearch.action.search.SearchResponse response) migrate
(int batchSize) 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) org.opensearch.action.search.SearchResponse
search
(org.opensearch.action.search.SearchRequest request) 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, 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
getLogEntriesAfter, getLogEntriesFor, nativeQuery, nativeQueryLogs, queryLogs, queryLogsByPage, queryLogsByPage, queryLogsByPage
-
Field Details
-
SEQ_NAME
- See Also:
-
MIGRATION_FLAG_PROP
- See Also:
-
MIGRATION_BATCH_SIZE_PROP
- See Also:
-
MIGRATION_DONE_EVENT
- See Also:
-
MIGRATION_DEFAULT_BACTH_SIZE
public static final int MIGRATION_DEFAULT_BACTH_SIZE- See Also:
-
AUDIT_LATEST_LOG_ID_AFTER_DATE_PROP
- See Also:
-
latestLogIdAfterDate
-
cursorService
protected CursorService<Iterator<org.opensearch.search.SearchHit>,org.opensearch.search.SearchHit, cursorServiceString> -
esClient
-
provider
-
-
Constructor Details
-
ESAuditBackend
-
ESAuditBackend
public ESAuditBackend()- Since:
- 9.3
-
-
Method Details
-
getClient
-
isMigrationDone
protected boolean isMigrationDone() -
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
-
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
-
createSearchRequestSource
protected org.opensearch.search.builder.SearchSourceBuilder createSearchRequestSource(MultiExpression predicate, OrderByList orders) -
createQueryBuilder
-
buildLogEntries
-
createSearchRequest
protected org.opensearch.action.search.SearchRequest createSearchRequest() -
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
-
buildQuery
-
createSearchSourceBuilder
-
expandQueryVariables
-
expandQueryVariables
-
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
-
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
-
search
public org.opensearch.action.search.SearchResponse search(org.opensearch.action.search.SearchRequest request) -
buildFilter
protected org.opensearch.index.query.QueryBuilder buildFilter(PredicateDefinition[] predicates, DocumentModel searchDocumentModel) -
convertDate
-
buildSearchQuery
public org.opensearch.action.search.SearchRequest buildSearchQuery(String fixedPart, PredicateDefinition[] predicates, DocumentModel searchDocumentModel) -
isNonNullParam
-
migrate
-
logSearchResponse
protected void logSearchResponse(org.opensearch.action.search.SearchResponse response) -
logSearchRequest
protected void logSearchRequest(org.opensearch.action.search.SearchRequest request) -
ensureUIDSequencer
Ensures the audit sequence returns an UID greater or equal than the maximum log entry id. -
newExtendedInfo
Description copied from interface:AuditLogger
Create a new ExtendedInfo instance- Specified by:
newExtendedInfo
in interfaceAuditLogger
- Specified by:
newExtendedInfo
in classAbstractAuditBackend
-
getESIndexName
-
append
- Specified by:
append
in interfaceAuditStorage
-
scroll
- Specified by:
scroll
in interfaceAuditStorage
-
scroll
- Specified by:
scroll
in interfaceAuditStorage
-
getLatestLogId
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
-
getLatestLogIdAfterDate
-