From 68c8f5c6b8ec5fcf507dbc3f8fcc8d00ee7b8027 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 20 Nov 2023 19:47:53 -0800 Subject: [PATCH] Add @Transactional to controller. --- .../main/java/com/wisemapping/rest/BaseController.java | 10 ++++------ .../java/com/wisemapping/rest/MindmapController.java | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java index c8630100..9f5c60e4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java @@ -21,12 +21,14 @@ import com.wisemapping.exceptions.ClientException; import com.wisemapping.exceptions.OAuthAuthenticationException; import com.wisemapping.exceptions.Severity; import com.wisemapping.exceptions.ValidationException; -import com.wisemapping.service.NotificationService; import com.wisemapping.model.User; import com.wisemapping.rest.model.RestErrors; import com.wisemapping.security.Utils; +import com.wisemapping.service.NotificationService; import com.wisemapping.service.RegistrationException; -import org.apache.logging.log4j.Level; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -39,10 +41,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; -import jakarta.servlet.ServletContext; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - import java.lang.reflect.UndeclaredThrowableException; import java.util.Locale; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 29e3fed7..d188ec0f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -24,7 +24,6 @@ import com.wisemapping.rest.model.*; import com.wisemapping.security.Utils; import com.wisemapping.service.*; import com.wisemapping.validator.MapInfoValidator; -import jakarta.transaction.Transactional; import org.apache.commons.validator.routines.EmailValidator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -36,6 +35,8 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; @@ -48,7 +49,7 @@ import java.util.stream.Collectors; @Controller -@Transactional +@Transactional(propagation = Propagation.REQUIRED) @PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')") public class MindmapController extends BaseController { final Logger logger = LogManager.getLogger();