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..d2ccb839e 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; @@ -40,6 +41,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(); @@ -63,9 +72,14 @@ public void processUpgrade(String oldVersion, String newVersion) { if (profile==null) { profile=organizationService.getUserProfileHandler().createUserProfileInstance(username); } - profile.setAttribute(UserProfile.OTHER_KEYS[2],"true"); - organizationService.getUserProfileHandler().saveUserProfile(profile,true); - LOG.debug("External info added in gatein profile for user {}, {}ms", username, System.currentTimeMillis() - startTimeForUser); + // do not update the profiles of users who already have the correct external property value + if (profile.getAttribute(UserProfile.OTHER_KEYS[2]) != null && String.valueOf(true).equals(profile.getAttribute(UserProfile.OTHER_KEYS[2]))) { + LOG.debug("External info already set in gatein profile for user {}", username); + } else { + profile.setAttribute(UserProfile.OTHER_KEYS[2],"true"); + organizationService.getUserProfileHandler().saveUserProfile(profile,true); + LOG.debug("External info added in gatein profile for user {}, {}ms", username, System.currentTimeMillis() - startTimeForUser); + } } catch (Exception e) { LOG.error("Unable to get profile for user {}",username); } diff --git a/data-upgrade-users/src/main/resources/conf/portal/configuration.xml b/data-upgrade-users/src/main/resources/conf/portal/configuration.xml index 1f94e0e9b..09052fec2 100644 --- a/data-upgrade-users/src/main/resources/conf/portal/configuration.xml +++ b/data-upgrade-users/src/main/resources/conf/portal/configuration.xml @@ -60,7 +60,7 @@ 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