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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected CursorService<Iterator<org.opensearch.search.SearchHit>,org.opensearch.search.SearchHit, String> protected ESClientprotected Stringstatic final Stringstatic final intstatic final Stringstatic final Stringprotected BaseLogEntryProviderstatic final StringFields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET -
Constructor Summary
ConstructorsConstructorDescriptionESAuditBackend(NXAuditEventsService component, AuditBackendDescriptor config) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLogEntries(List<LogEntry> entries) Adds given log entries.voidprotected org.opensearch.index.query.QueryBuilderbuildFilter(PredicateDefinition[] predicates, DocumentModel searchDocumentModel) buildLogEntries(org.opensearch.action.search.SearchResponse searchResponse) org.opensearch.action.search.SearchRequestbuildQuery(String query, Map<String, Object> params) org.opensearch.action.search.SearchRequestbuildSearchQuery(String fixedPart, PredicateDefinition[] predicates, DocumentModel searchDocumentModel) protected voidclearScrollContext(org.opensearch.action.search.SearchResponse response) protected Objectprotected org.opensearch.index.query.QueryBuildercreateQueryBuilder(MultiExpression andPredicate) protected org.opensearch.action.search.SearchRequestprotected org.opensearch.search.builder.SearchSourceBuildercreateSearchRequestSource(MultiExpression predicate, OrderByList orders) protected org.opensearch.search.builder.SearchSourceBuildercreateSearchSourceBuilder(String query) protected voidensureUIDSequencer(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) intprotected ESClientprotected StringgetEventsCount(String eventId) longgetLatestLogId(String repositoryId, String... eventIds) Returns the latest log id matching events and repository or 0 when no match found.protected StringgetLogEntryByID(long id) Returns a given log entry given its id.protected booleanprotected booleanisNonNullParam(Object[] val) protected voidlogSearchRequest(org.opensearch.action.search.SearchRequest request) protected voidlogSearchResponse(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 instancevoidvoidqueryLogs(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.SearchResponsesearch(org.opensearch.action.search.SearchRequest request) 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, doCreateAndFillEntryFromDocument, doPutExtendedInfos, doSyncNode, getAuditableEventNames, getLogEntriesAfter, guardedDocument, guardedDocumentChildren, isAuditable, logEvent, logEvents, newLogEntry, populateExtendedInfo, restore, syncLogCreationEntriesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.platform.audit.service.AuditBackend
restoreMethods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditLogger
await, buildEntryFromEvent, getAuditableEventNames, logEvent, logEvents, newLogEntryMethods 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:
getApplicationStartedOrderin interfaceAuditBackend
-
onApplicationStarted
public void onApplicationStarted()- Specified by:
onApplicationStartedin interfaceAuditBackend
-
onApplicationStopped
public void onApplicationStopped()- Specified by:
onApplicationStoppedin interfaceAuditBackend
-
queryLogs
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
-
clearScrollContext
protected void clearScrollContext(org.opensearch.action.search.SearchResponse response) -
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:AuditReaderReturns a given log entry given its id.- Specified by:
getLogEntryByIDin interfaceAuditReader- Parameters:
id- the log entry identifier- Returns:
- a LogEntry instance
-
buildQuery
-
createSearchSourceBuilder
-
expandQueryVariables
-
expandQueryVariables
-
nativeQuery
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
Description copied from interface:AuditLoggerAdds given log entries.- Specified by:
addLogEntriesin interfaceAuditLogger- Parameters:
entries- the list of log entries.
-
getEventsCount
- Specified by:
getEventsCountin interfaceAuditAdmin
-
syncLogCreationEntries
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
-
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:AuditLoggerCreate a new ExtendedInfo instance- Specified by:
newExtendedInfoin interfaceAuditLogger- Specified by:
newExtendedInfoin classAbstractAuditBackend
-
getESIndexName
-
append
- Specified by:
appendin interfaceAuditStorage
-
scroll
- Specified by:
scrollin interfaceAuditStorage
-
scroll
- Specified by:
scrollin interfaceAuditStorage
-
getLatestLogId
Description copied from interface:AuditReaderReturns the latest log id matching events and repository or 0 when no match found.- Specified by:
getLatestLogIdin interfaceAuditReader- Overrides:
getLatestLogIdin classAbstractAuditBackend
-
getLatestLogIdAfterDate
-