Skip to content

Commit

Permalink
AYS-297 | Usage of @Transactional Annotation Has Been Fixed (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
agitrubard authored Sep 14, 2024
1 parent 6f61411 commit a61440a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public AdminRegistrationApplication findSummaryById(String id) {
* @return A response object containing the created register application.
*/
@Override
@Transactional
public AdminRegistrationApplication create(AdminRegistrationApplicationCreateRequest request) {

boolean isInstitutionExists = institutionReadPort.existsByIdAndIsStatusActive(request.getInstitutionId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class AdminRegistrationCompleteServiceImpl implements AdminRegistrationCompleteS
* @param completeRequest The request containing necessary information to complete the registration.
* This includes user details such as email, phone number, and password.
* @throws AdminRegistrationApplicationNotExistException if the registration application does not exist or is not in a waiting state.
* @throws AysUserAlreadyExistsByEmailAddressException if a user with the given email already exists.
* @throws AysUserAlreadyExistsByPhoneNumberException if a user with the given phone number already exists.
* @throws AysUserAlreadyExistsByEmailAddressException if a user with the given email already exists.
* @throws AysUserAlreadyExistsByPhoneNumberException if a user with the given phone number already exists.
*/
@Override
@Transactional
public void complete(final String id, final AdminRegistrationApplicationCompleteRequest completeRequest) {

log.trace("Admin Register Flow call starting for email of {}", completeRequest.getEmailAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.ays.auth.util.exception.AysUserNotActiveException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -67,6 +68,7 @@ class AysAuthServiceImpl implements AysAuthService {
* @throws AysUserDoesNotAccessPageException If the user does not have permission to access the requested page.
*/
@Override
@Transactional
public AysToken authenticate(final AysLoginRequest loginRequest) {

final AysUser user = userReadPort.findByEmailAddress(loginRequest.getEmailAddress())
Expand Down Expand Up @@ -170,6 +172,7 @@ private void validateUserStatus(final AysUser user) {
* @param refreshToken the refresh token used to invalidate the associated access token and refresh token
*/
@Override
@Transactional
public void invalidateTokens(final String refreshToken) {

tokenService.verifyAndValidate(refreshToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.ays.auth.service.AysInvalidTokenService;
import org.ays.auth.util.exception.AysTokenAlreadyInvalidatedException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -35,6 +36,7 @@ class AysInvalidTokenServiceImpl implements AysInvalidTokenService {
* @param tokenIds the set of token IDs to invalidate
*/
@Override
@Transactional
public void invalidateTokens(final Set<String> tokenIds) {
final Set<AysInvalidToken> invalidTokens = tokenIds.stream()
.map(tokenId -> AysInvalidToken.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.ays.auth.util.exception.AysUserNotSuperAdminException;
import org.ays.institution.model.Institution;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;
Expand All @@ -27,6 +28,7 @@
* </p>
*/
@Service
@Transactional
@RequiredArgsConstructor
class AysRoleCreateServiceImpl implements AysRoleCreateService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.ays.auth.util.exception.AysRoleNotExistByIdException;
import org.ays.auth.util.exception.AysUserNotSuperAdminException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;
Expand All @@ -28,6 +29,7 @@
* ensuring permissions and role name uniqueness are validated before saving.
*/
@Service
@Transactional
@RequiredArgsConstructor
class AysRoleUpdateServiceImpl implements AysRoleUpdateService {

Expand Down Expand Up @@ -107,9 +109,9 @@ public void activate(String id) {
* </p>
*
* @param id The ID of the role to passivate.
* @throws AysRoleNotExistByIdException if a role with the given ID does not exist.
* @throws AysRoleNotExistByIdException if a role with the given ID does not exist.
* @throws AysRoleAssignedToUserException if any user is assigned to the role.
* @throws AysInvalidRoleStatusException if the role's current status is not {@link AysRoleStatus#ACTIVE}.
* @throws AysInvalidRoleStatusException if the role's current status is not {@link AysRoleStatus#ACTIVE}.
*/
@Override
public void passivate(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.ays.common.util.AysRandomUtil;
import org.ays.institution.model.Institution;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;
Expand All @@ -33,6 +34,7 @@
* </p>
*/
@Service
@Transactional
@RequiredArgsConstructor
class AysUserCreateServiceImpl implements AysUserCreateService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.ays.common.util.AysRandomUtil;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.Optional;
Expand Down Expand Up @@ -47,6 +48,7 @@ class AysUserPasswordServiceImpl implements AysUserPasswordService {
* @throws AysEmailAddressNotValidException if the email address does not correspond to any existing user.
*/
@Override
@Transactional
public void forgotPassword(final AysPasswordForgotRequest forgotPasswordRequest) {

final String emailAddress = forgotPasswordRequest.getEmailAddress();
Expand Down Expand Up @@ -106,6 +108,7 @@ public void checkPasswordChangingValidity(final String passwordId) {
* the elapsed time or other conditions that prevent the password from being changed.
*/
@Override
@Transactional
public void createPassword(final String passwordId,
final AysPasswordCreateRequest createRequest) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.ays.auth.util.exception.AysUserNotPassiveException;
import org.ays.common.model.AysPhoneNumber;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;
Expand All @@ -29,6 +30,7 @@
* This service handles the update operation of existing users based on the provided update request.
*/
@Service
@Transactional
@RequiredArgsConstructor
class AysUserUpdateServiceImpl implements AysUserUpdateService {

Expand Down

0 comments on commit a61440a

Please sign in to comment.