-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Prevent external users from receiving notifications of published news from a space which they are not members - EXO-69079 #200
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add log here to show progression: nb of users executed/ total number of users There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
} catch (Exception e) { | ||
LOG.error("Unable to get profile for user {}",username); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ | |
<external-component-plugins> | ||
<target-component>org.exoplatform.commons.upgrade.UpgradeProductService</target-component> | ||
<component-plugin> | ||
<name>ExternalUserUpgradePlugin</name> | ||
<name>ExternalUserUpgradePluginV1</name> | ||
<set-method>addUpgradePlugin</set-method> | ||
<type>org.exoplatform.migration.UserSetExternalInGateinPortal</type> | ||
<description>Add external information in gatein portal profile</description> | ||
|
@@ -74,7 +74,7 @@ | |
<name>plugin.upgrade.target.version</name> | ||
<description>The plugin target version (will not be executed if previous version is equal or higher than 6.3.1) | ||
</description> | ||
<value>6.3.0</value> | ||
<value>6.6.x</value> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 6.6.x -> 6.6.0 @sofyenne ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is just to test acceptance, we set the correct version for the merge! |
||
</value-param> | ||
<value-param> | ||
<name>plugin.execution.order</name> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need that @sofyenne ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure that the upgrade plugin executes only once!