Skip to content

Commit

Permalink
flush
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Gorzala committed Dec 26, 2023
1 parent fc7d4d7 commit 5246671
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.dancier.dancer.core.exception.UnresolvableZipCode;
import net.dancier.dancer.security.AuthenticatedUser;
import net.dancier.dancer.security.CurrentUser;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/dancier/dancer/core/ProfileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void updateProfileForUserId(UUID userId, ProfileOfCurrentUserDto profileO
handleDancerProfiles(dancer, profileOfCurrentUserDto);
dancer.setUpdatedAt(Instant.now());
dancerRepository.save(dancer);
dancerRepository.flush();
log.info("{}/{}", dancer.getVersion(), oldVersion);
if (!dancer.getVersion().equals(oldVersion)) {
log.info("Profile-Change detected");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public ResponseEntity publish(@RequestBody NewEventlogDto newEventlogDto) {
Eventlog eventlog = EventlogMapper.toEventlog(newEventlogDto);
setRolesAndUser(eventlog);
eventlogService.appendNew(eventlog);

log.info("Appended " + eventlog + " to the eventlog.");
return ResponseEntity.ok().build();
}


private void setRolesAndUser(Eventlog eventlog) {
switch (SecurityContextHolder.getContext().getAuthentication().getPrincipal()) {
case AuthenticatedUser authenticatedUser -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.sql.SQLException;
import java.time.Instant;
import java.util.Set;
import java.util.UUID;

@Service
Expand All @@ -16,7 +17,11 @@ public class EventlogService {

private final EventlogDAO eventlogDAO;

private final static Set ALL_ALLOWED_TOPICS = Set.of("Foo");
private final static Set TOPICS_THAT_REQUIRE_A_USER = Set.of();

public void appendNew(Eventlog eventlog) {

try {
eventlog.setId(UUID.randomUUID());
eventlog.setCreated(Instant.now());
Expand All @@ -26,4 +31,11 @@ public void appendNew(Eventlog eventlog) {
}
}

private void validateTopic(Eventlog eventlog) {

}
private void authorize(Eventlog eventlog) {
String topic = eventlog.getTopic();
}

}

0 comments on commit 5246671

Please sign in to comment.