Implementation of jpa saving for traffic traces.
This commit is contained in:
@@ -25,6 +25,10 @@ public class CustomUserDetails implements UserDetails {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user.id().toString();
|
||||
|
||||
@@ -26,7 +26,11 @@ public class TrafficTraceUseCases {
|
||||
}
|
||||
|
||||
@Async
|
||||
public void saveNewTrace(TrafficEndpoint trafficEndpoint, @Nullable String correlationId) {
|
||||
public void saveNewTrace(
|
||||
TrafficEndpoint trafficEndpoint,
|
||||
@Nullable UUID userId,
|
||||
@Nullable String correlationId
|
||||
) {
|
||||
if (isNull(trafficEndpoint)) {
|
||||
throw new TrafficTraceCreationException("Traffic endpoint should not be null.");
|
||||
}
|
||||
@@ -35,6 +39,7 @@ public class TrafficTraceUseCases {
|
||||
.withId(UUID.randomUUID())
|
||||
.withDateTime(ZonedDateTime.now(clock))
|
||||
.withEndpoint(trafficEndpoint)
|
||||
.withUserId(userId)
|
||||
.withCorrelationId(correlationId)
|
||||
.build();
|
||||
trafficTracePort.save(newTrace);
|
||||
|
||||
@@ -87,9 +87,7 @@ public class UserUseCases {
|
||||
.map(Authentication::getPrincipal)
|
||||
.filter(CustomUserDetails.class::isInstance)
|
||||
.map(CustomUserDetails.class::cast)
|
||||
.map(CustomUserDetails::getUsername)
|
||||
.map(UUID::fromString)
|
||||
.flatMap(userPort::findById);
|
||||
.map(CustomUserDetails::getUser);
|
||||
}
|
||||
|
||||
private UserAuthenticationData generateAuthenticationData(User user) {
|
||||
|
||||
Reference in New Issue
Block a user