Hello Ravi Nori,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/18401
to review the following change.
Change subject: webadmin: Error when changing email address for user event
notification
......................................................................
webadmin: Error when changing email address for user event notification
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 <[email protected]>
---
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/01/18401/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/18401
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If30c1e935cad06b293589c80922f56ee377375cb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: Ravi Nori <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches