From 4484b89c9513747d6c31e3f1f91cf4d8b65a0df6 Mon Sep 17 00:00:00 2001 From: Sofien Haj Chedhli Date: Mon, 29 Jan 2024 16:13:42 +0100 Subject: [PATCH] fix: Prevent external users from receiving notifications of published news from a space which they are not members - EXO-69079 (#200) Prior to this change, external users were receiving notifications of published news from a space in which they were not members. This issue was caused by the absence of external property information in the gatein profile, which was only present in the social profile. After updating the ExternalUersLinstenerImp to set the external status in the gatein profile for the newly created users , this change will re-execute the ExternalUserUpgradePlugin to set the external status in the gatein profile for the previously created users. --- .../UserSetExternalInGateinPortal.java | 26 ++++++++++++++++--- .../resources/conf/portal/configuration.xml | 4 +-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/data-upgrade-users/src/main/java/org/exoplatform/migration/UserSetExternalInGateinPortal.java b/data-upgrade-users/src/main/java/org/exoplatform/migration/UserSetExternalInGateinPortal.java index 5a2975d48..c8c17b130 100644 --- a/data-upgrade-users/src/main/java/org/exoplatform/migration/UserSetExternalInGateinPortal.java +++ b/data-upgrade-users/src/main/java/org/exoplatform/migration/UserSetExternalInGateinPortal.java @@ -16,6 +16,7 @@ */ package org.exoplatform.migration; +import org.exoplatform.commons.upgrade.UpgradePluginExecutionContext; import org.exoplatform.commons.upgrade.UpgradeProductPlugin; import org.exoplatform.commons.utils.ListAccess; import org.exoplatform.container.ExoContainerContext; @@ -29,6 +30,7 @@ import org.exoplatform.services.organization.UserProfile; import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; public class UserSetExternalInGateinPortal extends UpgradeProductPlugin { private static final Log LOG = ExoLogger.getExoLogger(UserSetExternalInGateinPortal.class); @@ -40,6 +42,14 @@ public UserSetExternalInGateinPortal(OrganizationService organizationService,Ini } @Override + public boolean shouldProceedToUpgrade(String newVersion, + String previousGroupVersion, + UpgradePluginExecutionContext previousUpgradePluginExecution) { + + int executionCount = previousUpgradePluginExecution == null ? 0 : previousUpgradePluginExecution.getExecutionCount(); + return !isExecuteOnlyOnce() || executionCount == 0; + } + @Override public void processUpgrade(String oldVersion, String newVersion) { LOG.info("Start upgrade process to add external info in gatein user profile"); long startupTime = System.currentTimeMillis(); @@ -50,7 +60,8 @@ public void processUpgrade(String oldVersion, String newVersion) { LOG.info("Number of users to update : " + total); int pageSize = 100; - int current=0; + int current = 0; + AtomicInteger updatedUserProfiles = new AtomicInteger(0); while (current org.exoplatform.commons.upgrade.UpgradeProductService - ExternalUserUpgradePlugin + ExternalUserUpgradePluginV1 addUpgradePlugin org.exoplatform.migration.UserSetExternalInGateinPortal Add external information in gatein portal profile @@ -74,7 +74,7 @@ plugin.upgrade.target.version The plugin target version (will not be executed if previous version is equal or higher than 6.3.1) - 6.3.0 + 6.6.x plugin.execution.order