Skip to content
Snippets Groups Projects
Commit 24f8a2d8 authored by MZhu9's avatar MZhu9
Browse files

1. add new audit event for reindex records API

2. switch from storage query/records:batch API to query/records API
parent b3e82e3a
No related branches found
No related tags found
1 merge request!556Implement reindex records API
......@@ -82,7 +82,7 @@ public class ReindexApi {
Records records = this.reIndexService.reindexRecords(reindexRecordsRequest.getRecordIds());
List<String> reindexedRecords = records.getRecords().stream().map(Records.Entity::getId).collect(Collectors.toList());
if (!reindexedRecords.isEmpty()) {
this.auditLogger.getReindex(reindexedRecords);
this.auditLogger.getReindexRecords(reindexedRecords);
}
return new ResponseEntity<>(ReindexRecordsResponse.builder().reIndexedRecords(records.getRecords().stream().map(Records.Entity::getId).collect(Collectors.toList())).notFoundRecords(records.getNotFound()).build(), HttpStatus.ACCEPTED);
}
......
......@@ -63,6 +63,9 @@ public class AuditEvents {
private static final String INDEX_DELETE_SUCCESS = "Successfully deleted index";
private static final String INDEX_DELETE_FAILURE = "Failed deleting index";
private static final String REINDEX_RECORDS_ACTION_ID = "IN0014";
private static final String REINDEX_RECORDS_OPERATION = "Reindex records";
private final String user;
public AuditEvents(String user) {
......@@ -204,6 +207,17 @@ public class AuditEvents {
.build();
}
public AuditPayload getReindexRecordsEvent(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.CREATE)
.status(AuditStatus.SUCCESS)
.actionId(REINDEX_RECORDS_ACTION_ID)
.message(REINDEX_RECORDS_OPERATION)
.resources(resources)
.user(this.user)
.build();
}
public AuditPayload getCopyIndexEvent(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.CREATE)
......@@ -269,4 +283,4 @@ public class AuditEvents {
.build();
}
}
}
\ No newline at end of file
}
......@@ -89,6 +89,10 @@ public class AuditLogger {
this.writeLog(this.getAuditEvents().getReindexEvent(resources));
}
public void getReindexRecords(List<String> resources) {
this.writeLog(this.getAuditEvents().getReindexRecordsEvent(resources));
}
public void copyIndex(List<String> resources) {
this.writeLog(this.getAuditEvents().getCopyIndexEvent(resources));
}
......@@ -116,4 +120,4 @@ public class AuditLogger {
private void writeLog(AuditPayload log) {
this.logger.audit(log);
}
}
\ No newline at end of file
}
......@@ -137,8 +137,7 @@ public class StorageServiceImpl implements StorageService {
protected Records getRecords(List<String> ids) throws URISyntaxException {
String body = this.gson.toJson(RecordIds.builder().records(ids).build());
DpsHeaders headers = this.requestInfo.getHeaders();
headers.put(FRAME_OF_REFERENCE, SLB_FRAME_OF_REFERENCE_VALUE);
URIBuilder builder = new URIBuilder(configurationProperties.getStorageQueryRecordForConversionHost());
URIBuilder builder = new URIBuilder(configurationProperties.getStorageQueryRecordHost());
HttpPost request = new HttpPost(builder.build());
request.setEntity(new StringEntity(body, StandardCharsets.UTF_8));
// we do not need retry on storage based on not found record
......
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