use of org.cloudfoundry.credhub.exceptions.AuditSaveFailureException in project credhub by cloudfoundry-incubator.
the class EventAuditLogService method writeAuditRecords.
private void writeAuditRecords(List<EventAuditRecordParameters> eventAuditRecordParametersList, boolean success, TransactionStatus transaction) {
try {
if (!success) {
transactionManager.rollback(transaction);
transaction = transactionManager.getTransaction(new DefaultTransactionDefinition());
}
final UUID uuid = requestUuid.getUuid();
final List<EventAuditRecord> eventAuditRecords = eventAuditRecordParametersList.stream().map(parameters -> AuditLogFactory.createEventAuditRecord(parameters, userContextHolder.getUserContext(), uuid, success)).collect(Collectors.toList());
eventAuditRecordDataService.save(eventAuditRecords);
transactionManager.commit(transaction);
} catch (Exception e) {
throw new AuditSaveFailureException("error.audit_save_failure", e);
} finally {
if (!transaction.isCompleted()) {
transactionManager.rollback(transaction);
}
}
}
Aggregations