Skip to content

Commit 6f5ba54

Browse files
boubakerexo-swf
authored andcommitted
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.
1 parent 25f775e commit 6f5ba54

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

services/src/main/java/io/meeds/gamification/storage/cached/ProgramCachedStorage.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
import java.util.concurrent.CompletableFuture;
2929

3030
import org.apache.commons.lang3.StringUtils;
31-
import org.apache.commons.collections4.CollectionUtils;
3231

3332
import org.exoplatform.commons.cache.future.FutureCache;
3433
import org.exoplatform.commons.cache.future.FutureExoCache;
3534
import org.exoplatform.commons.cache.future.Loader;
3635
import org.exoplatform.commons.file.services.FileService;
3736
import org.exoplatform.container.PortalContainer;
3837
import org.exoplatform.container.RootContainer.PortalContainerPostCreateTask;
38+
import org.exoplatform.portal.config.UserACL;
3939
import org.exoplatform.services.cache.CacheService;
4040
import org.exoplatform.services.cache.CachedObjectSelector;
4141
import org.exoplatform.services.cache.ExoCache;
@@ -65,6 +65,8 @@ public class ProgramCachedStorage extends ProgramStorage {
6565

6666
public static final String PROGRAM_CACHE_NAME = "gamification.domain";
6767

68+
private UserACL userAcl;
69+
6870
private FutureExoCache<Long, ProgramDTO, Object> programFutureCache;
6971

7072
private FutureCache<Object, List<String>, Object> administratorsRetrivalTask;
@@ -218,10 +220,9 @@ public void postDelete(User user) throws Exception {
218220
@ContainerTransactional
219221
public void clearCachedAdministrator(User user) {
220222
if (administrators != null
223+
&& user != null
221224
&& (administrators.stream().anyMatch(u -> StringUtils.equals(u, user.getUserName()))
222-
|| CollectionUtils.isNotEmpty(organizationService.getMembershipHandler()
223-
.findMembershipsByUserAndGroup(user.getUserName(),
224-
Utils.REWARDING_GROUP)))) {
225+
|| userAcl.getUserIdentity(user.getUserName()).isMemberOf(Utils.REWARDING_GROUP))) {
225226
administrators = null;
226227
}
227228
}

0 commit comments

Comments
 (0)