Ravi Nori has uploaded a new change for review. Change subject: webadmin: Changing email address for event notification results in error "User is already subscribed to this event with the same Notification method" ......................................................................
webadmin: Changing email address for event notification results in error "User is already subscribed to this event with the same Notification method" When changing user event notification email, the web admin portal complains that the user is already subscribed to the events. This happens because we are executing 2 AsyncCalls from GWT to backend RemoveEventSubscription and AddEventSubscription. If all RemoveEventSubscription calls do not complete before AddEventSubscription action is called the exception is thrown. Change-Id: If30c1e935cad06b293589c80922f56ee377375cb Bug-Url: https://bugzilla.redhat.com/985635 Signed-off-by: Ravi Nori <rn...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/UserEventNotifierListModel.java 1 file changed, 30 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/84/17984/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/UserEventNotifierListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/UserEventNotifierListModel.java index 88f5441..9753dc9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/UserEventNotifierListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/UserEventNotifierListModel.java @@ -11,6 +11,7 @@ import org.ovirt.engine.core.common.action.EventSubscriptionParametesBase; import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.DbUser; import org.ovirt.engine.core.common.businessentities.event_subscriber; import org.ovirt.engine.core.common.queries.IdQueryParameters; @@ -25,6 +26,8 @@ import org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.EnumTranslator; +import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult; +import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback; import org.ovirt.engine.ui.uicompat.Translator; @SuppressWarnings("unused") @@ -284,19 +287,42 @@ if (toRemoveList.size() > 0) { + EventSubscriptionFrontendActionAsyncCallback callback = new EventSubscriptionFrontendActionAsyncCallback(toAddList, toRemoveList); for (VdcActionParametersBase param : toRemoveList) { - Frontend.RunAction(VdcActionType.RemoveEventSubscription, param); + Frontend.RunAction(VdcActionType.RemoveEventSubscription, param, callback); } - } - - if (toAddList.size() > 0) + } else if (toAddList.size() > 0) { Frontend.RunMultipleAction(VdcActionType.AddEventSubscription, toAddList); } cancel(); } + private final class EventSubscriptionFrontendActionAsyncCallback implements IFrontendActionAsyncCallback { + private ArrayList<VdcActionParametersBase> toAddList; + ArrayList<VdcActionParametersBase> toRemoveList; + private int sucessCount = 0; + + EventSubscriptionFrontendActionAsyncCallback(ArrayList<VdcActionParametersBase> toAddList, ArrayList<VdcActionParametersBase> toRemoveList) { + this.toAddList = toAddList; + this.toRemoveList = toRemoveList; + } + + @Override + public void executed(FrontendActionAsyncResult result) { + VdcReturnValueBase returnValue = result.getReturnValue(); + if (returnValue != null && returnValue.getSucceeded()) { + sucessCount++; + // we wait until all subscribed events have been removed and then + // invoke the AddEventSubscription action + if (toAddList.size() > 0 && sucessCount == toRemoveList.size()) { + Frontend.RunMultipleAction(VdcActionType.AddEventSubscription, toAddList); + } + } + } + } + public void cancel() { setWindow(null); -- To view, visit http://gerrit.ovirt.org/17984 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If30c1e935cad06b293589c80922f56ee377375cb Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <rn...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches