Skip to content

Commit

Permalink
Merge pull request #36 from RobJenks/audit-update
Browse files Browse the repository at this point in the history
Update audit log location
  • Loading branch information
RobJenks authored Jun 11, 2024
2 parents f982036 + dd59a50 commit b75ceaa
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.time.OffsetDateTime;
import java.util.Date;

public class ModelInterfaceStateMachineAuditLog {
private static final Logger LOG = LoggerFactory.getLogger(ModelInterfaceStateMachineAuditLog.class);
Expand All @@ -27,7 +28,7 @@ public void recordAudit(ModelInterfaceStateMachine model, ModelInterfaceState st
return;
}

final var filename = generateAuditRecordFilename(model, state, sessionId, identifier, content);
final var filename = generateAuditRecordFilename(model, sessionId, identifier, content);
try {
FileUtils.writeStringToFile(new File(filename), content, Charset.defaultCharset());
}
Expand All @@ -36,17 +37,16 @@ public void recordAudit(ModelInterfaceStateMachine model, ModelInterfaceState st
}
}

private String generateAuditRecordFilename(ModelInterfaceStateMachine model, ModelInterfaceState state, String sessionId, String identifier, String content) {
return String.format("%s%s%d-%s-%s-%s-%s.%s",
recordLocation,
File.separator,
private String generateAuditRecordFilename(ModelInterfaceStateMachine model, String sessionId, String identifier, String content) {
return Path.of(
recordLocation,
String.format("%d-%s-%s-%s.%s",
System.currentTimeMillis(),
new SimpleDateFormat("yyyy-MM-dd").format(OffsetDateTime.now()),
new SimpleDateFormat("yyyy-MM-dd").format(new Date()),
sessionId,
state.getId(),
identifier,
getAppropriateFileExtension(content)
);
getAppropriateFileExtension(content))
).toString();
}

private String getAppropriateFileExtension(String content) {
Expand Down

0 comments on commit b75ceaa

Please sign in to comment.