diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditEvents.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditEvents.java index 9ac4df7da845cbd6014f19d4e53602011ffb8dbb..1f0970f1db6b0a629b2dbfa7a34d1b3d54f11a04 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditEvents.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditEvents.java @@ -38,6 +38,9 @@ public class AuditEvents { 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_OPERATION = "Reindex kind"; @@ -151,6 +154,17 @@ public class AuditEvents { .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) { return AuditPayload.builder() .action(AuditAction.CREATE) diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditLogger.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditLogger.java index aaf148f82d20bbc05b674225cafe68a881dc4a52..431e99afc29e4f4714ce3121057ecae2a81891ed 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditLogger.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/logging/AuditLogger.java @@ -73,6 +73,10 @@ public class AuditLogger { this.writeLog(this.getAuditEvents().getIndexPurgeRecordFailEvent(resources)); } + public void indexStarted(List<String> resources) { + this.writeLog(this.getAuditEvents().getIndexEvent(resources)); + } + public void getReindex(List<String> resources) { this.writeLog(this.getAuditEvents().getReindexEvent(resources)); } diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java index 36f91af2405098e188a4113b009e165dfd4500be..e77ef8f0908bbf9e718562ad4322aa9284756f73 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java @@ -125,6 +125,10 @@ public class IndexerServiceImpl implements IndexerService { retryRecordIds.addAll(deleteFailureRecordIds); } + auditLogger.indexStarted(recordInfos.stream() + .map(RecordInfo::getKind) + .collect(Collectors.toList())); + // process schema change messages Map<String, OperationType> schemaMsgs = RecordInfo.getSchemaMsgs(recordInfos); if (schemaMsgs != null && !schemaMsgs.isEmpty()) {