public class ESAuditBackend extends AbstractAuditBackend implements AuditBackend
AuditBackend
interface using Elasticsearch persistenceModifier and Type | Class and Description |
---|---|
class |
ESAuditBackend.ESCursorResult |
Modifier and Type | Field and Description |
---|---|
protected CursorService<Iterator<org.elasticsearch.search.SearchHit>,org.elasticsearch.search.SearchHit,String> |
cursorService |
protected ESClient |
esClient |
protected static org.apache.commons.logging.Log |
log |
static String |
MIGRATION_BATCH_SIZE_PROP |
static int |
MIGRATION_DEFAULT_BACTH_SIZE |
static String |
MIGRATION_DONE_EVENT |
static String |
MIGRATION_FLAG_PROP |
protected BaseLogEntryProvider |
provider |
static String |
SEQ_NAME |
component, config, expressionEvaluator, FORCE_AUDIT_FACET
Constructor and Description |
---|
ESAuditBackend() |
ESAuditBackend(NXAuditEventsService component,
AuditBackendDescriptor config) |
Modifier and Type | Method and Description |
---|---|
void |
addLogEntries(List<LogEntry> entries)
Adds given log entries.
|
void |
append(List<String> jsonEntries) |
protected org.elasticsearch.index.query.QueryBuilder |
buildFilter(PredicateDefinition[] predicates,
DocumentModel searchDocumentModel) |
protected List<LogEntry> |
buildLogEntries(org.elasticsearch.action.search.SearchResponse searchResponse) |
org.elasticsearch.action.search.SearchRequest |
buildQuery(String query,
Map<String,Object> params) |
org.elasticsearch.action.search.SearchRequest |
buildSearchQuery(String fixedPart,
PredicateDefinition[] predicates,
DocumentModel searchDocumentModel) |
protected Object |
convertDate(Object o) |
protected org.elasticsearch.index.query.QueryBuilder |
createQueryBuilder(Predicate andPredicate) |
protected org.elasticsearch.action.search.SearchRequest |
createSearchRequest() |
protected org.elasticsearch.search.builder.SearchSourceBuilder |
createSearchRequestSource(Predicate predicate,
OrderByList orders) |
protected org.elasticsearch.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.
|
String |
expandQueryVariables(String query,
Map<String,Object> params) |
String |
expandQueryVariables(String query,
Object[] params) |
int |
getApplicationStartedOrder() |
protected ESClient |
getClient() |
protected String |
getESIndexName() |
Long |
getEventsCount(String eventId) |
LogEntry |
getLogEntryByID(long id)
Returns a given log entry given its id.
|
protected boolean |
isMigrationDone() |
protected boolean |
isNonNullParam(Object[] val) |
protected void |
logSearchRequest(org.elasticsearch.action.search.SearchRequest request) |
protected void |
logSearchResponse(org.elasticsearch.action.search.SearchResponse response) |
String |
migrate(int batchSize) |
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 instance
|
void |
onApplicationStarted() |
void |
onApplicationStopped() |
List<LogEntry> |
queryLogs(AuditQueryBuilder 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(AuditQueryBuilder builder,
int batchSize,
int keepAliveSeconds) |
ScrollResult<String> |
scroll(String scrollId) |
org.elasticsearch.action.search.SearchResponse |
search(org.elasticsearch.action.search.SearchRequest request) |
long |
syncLogCreationEntries(String repoId,
String path,
Boolean recurs)
Forces log Synchronisation for a branch of the repository.
|
await, buildEntryFromEvent, convert, doCreateAndFillEntryFromDocument, doPutExtendedInfos, doSyncNode, getAuditableEventNames, getLatestLogId, getLogEntriesAfter, getLogEntriesFor, guardedDocument, guardedDocumentChildren, isAuditable, logEvent, logEvents, newLogEntry, populateExtendedInfo, restore, syncLogCreationEntries
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, restore
getLatestLogId, getLogEntriesAfter, getLogEntriesFor, getLogEntriesFor, getLogEntriesFor, nativeQuery, nativeQueryLogs, queryLogs, queryLogsByPage, queryLogsByPage, queryLogsByPage
await, buildEntryFromEvent, getAuditableEventNames, logEvent, logEvents, newLogEntry
public static final String SEQ_NAME
public static final String MIGRATION_FLAG_PROP
public static final String MIGRATION_BATCH_SIZE_PROP
public static final String MIGRATION_DONE_EVENT
public static final int MIGRATION_DEFAULT_BACTH_SIZE
protected CursorService<Iterator<org.elasticsearch.search.SearchHit>,org.elasticsearch.search.SearchHit,String> cursorService
protected static final org.apache.commons.logging.Log log
protected BaseLogEntryProvider provider
public ESAuditBackend(NXAuditEventsService component, AuditBackendDescriptor config)
public ESAuditBackend()
protected boolean isMigrationDone()
public int getApplicationStartedOrder()
getApplicationStartedOrder
in interface AuditBackend
public void onApplicationStarted()
onApplicationStarted
in interface AuditBackend
public void onApplicationStopped()
onApplicationStopped
in interface AuditBackend
public List<LogEntry> queryLogs(AuditQueryBuilder builder)
AuditReader
queryLogs
in interface AuditReader
builder
- the query builder to fetch log entriesprotected org.elasticsearch.search.builder.SearchSourceBuilder createSearchRequestSource(Predicate predicate, OrderByList orders)
protected org.elasticsearch.index.query.QueryBuilder createQueryBuilder(Predicate andPredicate)
protected List<LogEntry> buildLogEntries(org.elasticsearch.action.search.SearchResponse searchResponse)
protected org.elasticsearch.action.search.SearchRequest createSearchRequest()
public LogEntry getLogEntryByID(long id)
AuditReader
getLogEntryByID
in interface AuditReader
id
- the log entry identifierpublic org.elasticsearch.action.search.SearchRequest buildQuery(String query, Map<String,Object> params)
protected org.elasticsearch.search.builder.SearchSourceBuilder createSearchSourceBuilder(String query)
public String expandQueryVariables(String query, Object[] params)
public List<?> nativeQuery(String query, Map<String,Object> params, int pageNb, int pageSize)
AuditReader
nativeQuery
in interface AuditReader
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 pagepublic List<LogEntry> queryLogsByPage(String[] eventIds, Date limit, String[] categories, String path, int pageNb, int pageSize)
queryLogsByPage
in interface AuditReader
queryLogsByPage
in class AbstractAuditBackend
public void addLogEntries(List<LogEntry> entries)
AuditLogger
addLogEntries
in interface AuditLogger
entries
- the list of log entries.public Long getEventsCount(String eventId)
getEventsCount
in interface AuditAdmin
public long syncLogCreationEntries(String repoId, String path, Boolean recurs)
AuditAdmin
syncLogCreationEntries
in interface AuditAdmin
public org.elasticsearch.action.search.SearchResponse search(org.elasticsearch.action.search.SearchRequest request)
protected org.elasticsearch.index.query.QueryBuilder buildFilter(PredicateDefinition[] predicates, DocumentModel searchDocumentModel)
protected Object convertDate(Object o)
public org.elasticsearch.action.search.SearchRequest buildSearchQuery(String fixedPart, PredicateDefinition[] predicates, DocumentModel searchDocumentModel)
protected boolean isNonNullParam(Object[] val)
protected void logSearchResponse(org.elasticsearch.action.search.SearchResponse response)
protected void logSearchRequest(org.elasticsearch.action.search.SearchRequest request)
protected void ensureUIDSequencer(ESClient esClient)
public ExtendedInfo newExtendedInfo(Serializable value)
AuditLogger
newExtendedInfo
in interface AuditLogger
newExtendedInfo
in class AbstractAuditBackend
protected String getESIndexName()
public void append(List<String> jsonEntries)
append
in interface AuditStorage
public ScrollResult<String> scroll(AuditQueryBuilder builder, int batchSize, int keepAliveSeconds)
scroll
in interface AuditStorage
public ScrollResult<String> scroll(String scrollId)
scroll
in interface AuditStorage
Copyright © 2018 Nuxeo. All rights reserved.