Revised transaction begin with check if it is already active. Added log of the storage ins use

This commit is contained in:
Mauro Mugnaini 2021-01-26 18:34:19 +01:00
parent 3c4294c2d5
commit 1424b10942
1 changed files with 8 additions and 4 deletions

View File

@ -57,9 +57,11 @@ public class DeleteAccountResource {
UserModel user = auth.getUser();
try {
logger.debug("Beginning the transaction on transaction manager");
session.getTransactionManager().begin();
if (!session.getTransactionManager().isActive()) {
logger.debug("Beginning a new transaction on transaction manager");
session.getTransactionManager().begin();
}
logger.debug("Finding user model and setting it as not enabled in realm");
session.users().getUserById(user.getId(), realm).setEnabled(false);
@ -71,9 +73,11 @@ public class DeleteAccountResource {
logger.error("Cannot perform user model modifications", e);
}
logger.debug("Getting the the configured avatar storage provider");
AvatarStorageProvider avatarStorageProvider = session.getProvider(AvatarStorageProvider.class);
if (avatarStorageProvider != null) {
logger.debug("Deleting avatar from storage for the user");
logger.tracev("Configured avatar storage provider type is {0}", avatarStorageProvider.getClass().getName());
logger.debug("Deleting user's avatar from the configured storage");
avatarStorageProvider.deleteAvatarImage(realm, user);
} else {
logger.warn("Cannot perform avatar import ince the avatar storage provider is null");