Code review fixes
This commit is contained in:
parent
12b8f77e2d
commit
7f1651c807
@ -323,8 +323,11 @@ audit_log:
|
|||||||
# Name of the index where audit logs stored
|
# Name of the index where audit logs stored
|
||||||
# Index name could contain next placeholders (not mandatory):
|
# Index name could contain next placeholders (not mandatory):
|
||||||
# @{TENANT} - substituted by tenant ID
|
# @{TENANT} - substituted by tenant ID
|
||||||
# @{DATE} - substituted by current date in YYYY.MM.DD format
|
# @{DATE} - substituted by current date in format provided in audit_log.sink.date_format
|
||||||
index_pattern: "${AUDIT_LOG_SINK_INDEX_PATTERN:@{TENANT}_AUDIT_LOG_@{DATE}}"
|
index_pattern: "${AUDIT_LOG_SINK_INDEX_PATTERN:@{TENANT}_AUDIT_LOG_@{DATE}}"
|
||||||
|
# Date format. Details of the pattern could be found here:
|
||||||
|
# https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
|
||||||
|
date_format: "${AUDIT_LOG_SINK_DATE_FORMAT:YYYY.MM.DD}"
|
||||||
scheme_name: "${AUDIT_LOG_SINK_SCHEME_NAME:http}" # http or https
|
scheme_name: "${AUDIT_LOG_SINK_SCHEME_NAME:http}" # http or https
|
||||||
host: "${AUDIT_LOG_SINK_HOST:localhost}"
|
host: "${AUDIT_LOG_SINK_HOST:localhost}"
|
||||||
port: "${AUDIT_LOG_SINK_POST:9200}"
|
port: "${AUDIT_LOG_SINK_POST:9200}"
|
||||||
|
|||||||
@ -300,7 +300,6 @@ public class AuditLogServiceImpl implements AuditLogService {
|
|||||||
futures.add(auditLogDao.saveByTenantIdAndCustomerId(auditLogEntry));
|
futures.add(auditLogDao.saveByTenantIdAndCustomerId(auditLogEntry));
|
||||||
futures.add(auditLogDao.saveByTenantIdAndUserId(auditLogEntry));
|
futures.add(auditLogDao.saveByTenantIdAndUserId(auditLogEntry));
|
||||||
|
|
||||||
// TODO: is this correct place to log action into sink?
|
|
||||||
auditLogSink.logAction(auditLogEntry);
|
auditLogSink.logAction(auditLogEntry);
|
||||||
|
|
||||||
return Futures.allAsList(futures);
|
return Futures.allAsList(futures);
|
||||||
|
|||||||
@ -50,8 +50,6 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
|
|||||||
|
|
||||||
private static final String TENANT_PLACEHOLDER = "@{TENANT}";
|
private static final String TENANT_PLACEHOLDER = "@{TENANT}";
|
||||||
private static final String DATE_PLACEHOLDER = "@{DATE}";
|
private static final String DATE_PLACEHOLDER = "@{DATE}";
|
||||||
private static final String DATE_FORMAT = "YYYY.MM.dd";
|
|
||||||
|
|
||||||
private static final String INDEX_TYPE = "audit_log";
|
private static final String INDEX_TYPE = "audit_log";
|
||||||
|
|
||||||
private final ObjectMapper mapper = new ObjectMapper();
|
private final ObjectMapper mapper = new ObjectMapper();
|
||||||
@ -68,6 +66,8 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
|
|||||||
private String userName;
|
private String userName;
|
||||||
@Value("${audit_log.sink.password}")
|
@Value("${audit_log.sink.password}")
|
||||||
private String password;
|
private String password;
|
||||||
|
@Value("${audit_log.sink.date_format}")
|
||||||
|
private String dateFormat;
|
||||||
|
|
||||||
private RestClient restClient;
|
private RestClient restClient;
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
|
|||||||
}
|
}
|
||||||
if (indexName.contains(DATE_PLACEHOLDER)) {
|
if (indexName.contains(DATE_PLACEHOLDER)) {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
|
||||||
indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter));
|
indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter));
|
||||||
}
|
}
|
||||||
return indexName.toLowerCase();
|
return indexName.toLowerCase();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user