From 7d2fd14abf427e6c41ab20cb1a2466336d412c34 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Thu, 29 Jan 2026 10:05:20 +0100 Subject: [PATCH] feat: Retrieve Memberships from User ACL instead of OrganizationService - MEED-10149 - Meeds-io/MIPs#240 (#1972) This change will centralize the users memberships retrieval to be made from `UserACL` Service rather than `OrganizationService`. This centralization will allow to optimize the Code enhancements and evolutivity. --- .../storage/cached/ProgramCachedStorage.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/src/main/java/io/meeds/gamification/storage/cached/ProgramCachedStorage.java b/services/src/main/java/io/meeds/gamification/storage/cached/ProgramCachedStorage.java index 162f2cb9f6..445110c914 100644 --- a/services/src/main/java/io/meeds/gamification/storage/cached/ProgramCachedStorage.java +++ b/services/src/main/java/io/meeds/gamification/storage/cached/ProgramCachedStorage.java @@ -28,7 +28,6 @@ import java.util.concurrent.CompletableFuture; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.collections4.CollectionUtils; import org.exoplatform.commons.cache.future.FutureCache; import org.exoplatform.commons.cache.future.FutureExoCache; @@ -36,6 +35,7 @@ import org.exoplatform.commons.file.services.FileService; import org.exoplatform.container.PortalContainer; import org.exoplatform.container.RootContainer.PortalContainerPostCreateTask; +import org.exoplatform.portal.config.UserACL; import org.exoplatform.services.cache.CacheService; import org.exoplatform.services.cache.CachedObjectSelector; import org.exoplatform.services.cache.ExoCache; @@ -65,6 +65,8 @@ public class ProgramCachedStorage extends ProgramStorage { public static final String PROGRAM_CACHE_NAME = "gamification.domain"; + private UserACL userAcl; + private FutureExoCache programFutureCache; private FutureCache, Object> administratorsRetrivalTask; @@ -218,10 +220,9 @@ public void postDelete(User user) throws Exception { @ContainerTransactional public void clearCachedAdministrator(User user) { if (administrators != null + && user != null && (administrators.stream().anyMatch(u -> StringUtils.equals(u, user.getUserName())) - || CollectionUtils.isNotEmpty(organizationService.getMembershipHandler() - .findMembershipsByUserAndGroup(user.getUserName(), - Utils.REWARDING_GROUP)))) { + || userAcl.getUserIdentity(user.getUserName()).isMemberOf(Utils.REWARDING_GROUP))) { administrators = null; } }