Package org.nuxeo.audit.opensearch1
Class OpenSearchAuditBackend
java.lang.Object
org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend<LogEntry>
org.nuxeo.audit.service.AbstractAuditBackend
org.nuxeo.audit.opensearch1.OpenSearchAuditBackend
- All Implemented Interfaces:
AuditBackend,AuditAdmin,AuditLogger<LogEntry>,AuditReader<LogEntry>,AuditStorage,Logs<LogEntry>,AuditBackend<LogEntry>
Implementation of the
AuditBackend interface using OpenSearch persistence- Author:
- tiry
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.nuxeo.audit.service.AuditBackend
AuditBackend.Capability -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected final OpenSearchClientprotected final CursorService<Iterator<org.opensearch.search.SearchHit>, org.opensearch.search.SearchHit, String> protected final Stringprotected Stringstatic final StringFields inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
component, config, expressionEvaluator, FORCE_AUDIT_FACET -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOpenSearchAuditBackend(OpenSearchClient client, String indexName) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLogEntries(List<LogEntry> entries) Adds given log entries.voidprotected org.opensearch.index.query.QueryBuilderbuildFilter(PredicateDefinition[] predicates, DocumentModel searchDocumentModel) protected LogEntryListbuildLogEntries(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 voidINTERNAL METHOD FOR TESTS, DO NOT USE.protected voidclearScrollContext(org.opensearch.action.search.SearchResponse response) protected Objectprotected org.opensearch.index.query.QueryBuildercreateQueryBuilder(Predicate queryPredicate) protected org.opensearch.action.search.SearchRequestprotected org.opensearch.search.builder.SearchSourceBuildercreateSearchRequestSource(MultiExpression predicate, OrderByList orders) protected org.opensearch.search.builder.SearchSourceBuildercreateSearchSourceBuilder(String query) expandQueryVariables(String query, Object[] params) expandQueryVariables(String query, Map<String, Object> params) getEventsCount(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.booleanhasCapability(AuditBackend.Capability capability) Checks whether the backend has the capability.protected static voidinitUIDSequencer(OpenSearchClient esClient, String indexName) Ensures the audit sequence returns an UID greater or equal than the maximum log entry id.protected booleanisNonNullParam(Object[] val) protected voidlogSearchRequest(org.opensearch.action.search.SearchRequest request) protected voidlogSearchResponse(org.opensearch.action.search.SearchResponse response) protected static org.opensearch.index.query.QueryBuildermakeStartsWithQuery(String name, Object value) List<?> nativeQuery(String query, Map<String, Object> params, int pageNb, int pageSize) Returns a batched list of entries.queryLogs(QueryBuilder builder) Returns the logs given a collection of predicates and a default sort.protected org.opensearch.action.search.SearchResponserunNextScroll(String scrollId, org.opensearch.common.unit.TimeValue keepAlive) scroll(QueryBuilder builder, int batchSize, int keepAliveSeconds) org.opensearch.action.search.SearchResponsesearch(org.opensearch.action.search.SearchRequest request) Methods inherited from class org.nuxeo.audit.service.AbstractAuditBackend
doCreateAndFillEntryFromDocument, getApplicationStartedOrder, newExtendedInfo, onApplicationStarted, onApplicationStopped, syncLogCreationEntriesMethods inherited from class org.nuxeo.ecm.platform.audit.service.AbstractAuditBackend
await, buildEntryFromEvent, doPutExtendedInfos, doSyncNode, getAuditableEventNames, guardedDocument, guardedDocumentChildren, isAuditable, 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.audit.service.AuditBackend
getLogEntriesForMethods inherited from interface org.nuxeo.ecm.platform.audit.service.AuditBackend
restoreMethods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditLogger
await, buildEntryFromEvent, getAuditableEventNames, newLogEntryMethods inherited from interface org.nuxeo.ecm.platform.audit.api.AuditReader
getLogEntriesAfter, nativeQuery, nativeQueryLogs, queryLogs, queryLogsByPage, queryLogsByPage, queryLogsByPage, queryLogsByPage
-
Field Details
-
SEQ_NAME
- See Also:
-
AUDIT_LATEST_LOG_ID_AFTER_DATE_PROP
- See Also:
-
client
-
indexName
-
cursorService
protected final CursorService<Iterator<org.opensearch.search.SearchHit>,org.opensearch.search.SearchHit, cursorServiceString> -
latestLogIdAfterDate
-
-
Constructor Details
-
OpenSearchAuditBackend
-
-
Method Details
-
queryLogs
Description copied from interface:AuditBackendReturns 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
-
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:AuditBackendReturns a given log entry given its id.- 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.- 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
-
addLogEntries
Description copied from interface:AuditBackendAdds given log entries.- Parameters:
entries- the list of log entries.
-
getEventsCount
-
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
-
runNextScroll
protected org.opensearch.action.search.SearchResponse runNextScroll(String scrollId, org.opensearch.common.unit.TimeValue keepAlive) -
logSearchResponse
protected void logSearchResponse(org.opensearch.action.search.SearchResponse response) -
logSearchRequest
protected void logSearchRequest(org.opensearch.action.search.SearchRequest request) -
initUIDSequencer
Ensures the audit sequence returns an UID greater or equal than the maximum log entry id. -
getIndexName
-
append
- Specified by:
appendin interfaceAuditStorage- Overrides:
appendin classAbstractAuditBackend
-
scroll
- Specified by:
scrollin interfaceAuditStorage- Overrides:
scrollin classAbstractAuditBackend
-
scroll
- Specified by:
scrollin interfaceAuditStorage- Overrides:
scrollin classAbstractAuditBackend
-
getLatestLogId
Description copied from interface:AuditBackendReturns the latest log id matching events and repository or 0 when no match found. -
getLatestLogIdAfterDate
-
clearEntries
protected void clearEntries()Description copied from class:AbstractAuditBackendINTERNAL METHOD FOR TESTS, DO NOT USE.- Overrides:
clearEntriesin classAbstractAuditBackend
-
makeStartsWithQuery
-
hasCapability
Description copied from interface:AuditBackendChecks whether the backend has the capability.
-