Code review fixes

This commit is contained in:
Volodymyr Babak 2018-02-28 12:32:25 +02:00
parent 12b8f77e2d
commit 7f1651c807
3 changed files with 7 additions and 5 deletions

View File

@ -323,8 +323,11 @@ audit_log:
# Name of the index where audit logs stored
# Index name could contain next placeholders (not mandatory):
# @{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}}"
# 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
host: "${AUDIT_LOG_SINK_HOST:localhost}"
port: "${AUDIT_LOG_SINK_POST:9200}"

View File

@ -300,7 +300,6 @@ public class AuditLogServiceImpl implements AuditLogService {
futures.add(auditLogDao.saveByTenantIdAndCustomerId(auditLogEntry));
futures.add(auditLogDao.saveByTenantIdAndUserId(auditLogEntry));
// TODO: is this correct place to log action into sink?
auditLogSink.logAction(auditLogEntry);
return Futures.allAsList(futures);

View File

@ -50,8 +50,6 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
private static final String TENANT_PLACEHOLDER = "@{TENANT}";
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 final ObjectMapper mapper = new ObjectMapper();
@ -68,6 +66,8 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
private String userName;
@Value("${audit_log.sink.password}")
private String password;
@Value("${audit_log.sink.date_format}")
private String dateFormat;
private RestClient restClient;
@ -152,7 +152,7 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
}
if (indexName.contains(DATE_PLACEHOLDER)) {
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter));
}
return indexName.toLowerCase();