Skip to content

Commit

Permalink
Fix unpublish application form from lambda (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicwest authored Mar 27, 2024
1 parent b6e0ad9 commit 78e684a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.odftoolkit.odfdom.doc.OdfTextDocument;

Expand Down Expand Up @@ -63,9 +65,11 @@ public class ApplicationFormService {
public ApplicationFormEntity save(ApplicationFormEntity applicationForm) {
final ApplicationFormEntity savedApplicationForm = applicationFormRepository.save(applicationForm);

Optional.ofNullable(HelperUtils.getAdminSessionForAuthenticatedUser())
.ifPresentOrElse(adminSession -> {
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
Optional.ofNullable(auth)
.ifPresentOrElse(authentication -> {
if (!HelperUtils.isAnonymousSession()) {
final AdminSession adminSession = (AdminSession) authentication.getPrincipal();
final SchemeEntity grantScheme = schemeRepository.findById(applicationForm.getGrantSchemeId())
.orElseThrow(() -> new EntityNotFoundException("Could not find grant scheme with ID" + applicationForm.getGrantSchemeId()));

Expand Down

0 comments on commit 78e684a

Please sign in to comment.