Skip to content
Snippets Groups Projects
Commit 1754e60b authored by Artem Dobrynin (EPAM)'s avatar Artem Dobrynin (EPAM)
Browse files

GONRG-1546: Audit. Implement some audit events for Indexer [publish]

parent f5631d9c
No related branches found
No related tags found
1 merge request!74Audit Logger Implementation (GONRG-1546)
...@@ -38,6 +38,9 @@ public class AuditEvents { ...@@ -38,6 +38,9 @@ public class AuditEvents {
private static final String INDEX_PURGE_RECORD_ACTION_ID = "IN004"; private static final String INDEX_PURGE_RECORD_ACTION_ID = "IN004";
private static final String INDEX_STARTED_ACTION_ID = "IN006";
private static final String INDEX_STARTED_OPERATION = "Indexing started";
private static final String REINDEX_KIND_ACTION_ID = "IN007"; private static final String REINDEX_KIND_ACTION_ID = "IN007";
private static final String REINDEX_KIND_OPERATION = "Reindex kind"; private static final String REINDEX_KIND_OPERATION = "Reindex kind";
...@@ -151,6 +154,17 @@ public class AuditEvents { ...@@ -151,6 +154,17 @@ public class AuditEvents {
.build(); .build();
} }
public AuditPayload getIndexEvent(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.CREATE)
.status(AuditStatus.SUCCESS)
.actionId(INDEX_STARTED_ACTION_ID)
.message(INDEX_STARTED_OPERATION)
.resources(resources)
.user(this.user)
.build();
}
public AuditPayload getReindexEvent(List<String> resources) { public AuditPayload getReindexEvent(List<String> resources) {
return AuditPayload.builder() return AuditPayload.builder()
.action(AuditAction.CREATE) .action(AuditAction.CREATE)
......
...@@ -73,6 +73,10 @@ public class AuditLogger { ...@@ -73,6 +73,10 @@ public class AuditLogger {
this.writeLog(this.getAuditEvents().getIndexPurgeRecordFailEvent(resources)); this.writeLog(this.getAuditEvents().getIndexPurgeRecordFailEvent(resources));
} }
public void indexStarted(List<String> resources) {
this.writeLog(this.getAuditEvents().getIndexEvent(resources));
}
public void getReindex(List<String> resources) { public void getReindex(List<String> resources) {
this.writeLog(this.getAuditEvents().getReindexEvent(resources)); this.writeLog(this.getAuditEvents().getReindexEvent(resources));
} }
......
...@@ -125,6 +125,10 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -125,6 +125,10 @@ public class IndexerServiceImpl implements IndexerService {
retryRecordIds.addAll(deleteFailureRecordIds); retryRecordIds.addAll(deleteFailureRecordIds);
} }
auditLogger.indexStarted(recordInfos.stream()
.map(RecordInfo::getKind)
.collect(Collectors.toList()));
// process schema change messages // process schema change messages
Map<String, OperationType> schemaMsgs = RecordInfo.getSchemaMsgs(recordInfos); Map<String, OperationType> schemaMsgs = RecordInfo.getSchemaMsgs(recordInfos);
if (schemaMsgs != null && !schemaMsgs.isEmpty()) { if (schemaMsgs != null && !schemaMsgs.isEmpty()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment