Gilad Chaplik has uploaded a new change for review.

Change subject: webadmin: consolidate Frontend.runQuery()
......................................................................

webadmin: consolidate Frontend.runQuery()

Currently there are two Frontend.runQuery methods, that behave the same, but 
have
a different signature. removing one of the methods (that is used only twice).

Change-Id: Ia306d5009f5e66d5203e5d9ad8135ae44fb65b3b
Signed-off-by: Gilad Chaplik <[email protected]>
---
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
D 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IFrontendQueryAsyncCallback.java
4 files changed, 45 insertions(+), 142 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/53/9553/1

diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
index 2df683c..aa19f29 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
@@ -29,12 +29,10 @@
 import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult;
 import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult;
 import org.ovirt.engine.ui.uicompat.FrontendMultipleQueryAsyncResult;
-import org.ovirt.engine.ui.uicompat.FrontendQueryAsyncResult;
 import org.ovirt.engine.ui.uicompat.IAsyncCallback;
 import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback;
 import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback;
 import org.ovirt.engine.ui.uicompat.IFrontendMultipleQueryAsyncCallback;
-import org.ovirt.engine.ui.uicompat.IFrontendQueryAsyncCallback;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -132,49 +130,6 @@
 
     public static void RunQuery(final VdcQueryType queryType,
             final VdcQueryParametersBase parameters,
-            final IFrontendQueryAsyncCallback callback) {
-        initQueryParamsFilter(parameters);
-        dumpQueryDetails(queryType, parameters);
-        logger.finer("Frontend: Invoking async runQuery."); //$NON-NLS-1$
-
-        GenericApiGWTServiceAsync service = 
GenericApiGWTServiceAsync.Util.getInstance();
-        service.RunQuery(queryType, parameters, new 
AsyncCallback<VdcQueryReturnValue>() {
-            @Override
-            public void onFailure(Throwable caught) {
-                if (ignoreFailure(caught)) {
-                    return;
-                }
-                logger.log(Level.SEVERE, "Failed to execute RunQuery: " + 
caught, caught); //$NON-NLS-1$
-                FrontendQueryAsyncResult f = new 
FrontendQueryAsyncResult(queryType, parameters, null);
-                getEventsHandler().runQueryFailed(null);
-                failureEventHandler(caught);
-                callback.OnFailure(f);
-            }
-
-            @Override
-            public void onSuccess(VdcQueryReturnValue result) {
-                logger.finer("Succesful returned result from RunQuery."); 
//$NON-NLS-1$
-                FrontendQueryAsyncResult f = new 
FrontendQueryAsyncResult(queryType, parameters, result);
-
-                if (!result.getSucceeded()) {
-                    logger.log(Level.WARNING, "Failure while invoking 
ReturnQuery [" + result.getExceptionString() //$NON-NLS-1$
-                            + "]"); //$NON-NLS-1$
-                    if (getEventsHandler() != null) {
-                        ArrayList<VdcQueryReturnValue> failedResult = new 
ArrayList<VdcQueryReturnValue>();
-                        failedResult.add(result);
-                        if 
(getEventsHandler().isRaiseErrorModalPanel(queryType))
-                            failureEventHandler(result.getExceptionString());
-                    }
-                    callback.OnFailure(f);
-                } else {
-                    callback.OnSuccess(f);
-                }
-            }
-        });
-    }
-
-    public static void RunQuery(final VdcQueryType queryType,
-            final VdcQueryParametersBase parameters,
             final AsyncQuery callback) {
         initQueryParamsFilter(parameters);
         dumpQueryDetails(queryType, parameters);
@@ -185,7 +140,7 @@
         service.RunQuery(queryType, parameters, new 
AsyncCallback<VdcQueryReturnValue>() {
             @Override
             public void onFailure(Throwable caught) {
-                if(ignoreFailure(caught)){
+                if (ignoreFailure(caught)) {
                     return;
                 }
                 logger.log(Level.SEVERE, "Failed to execute RunQuery: " + 
caught, caught); //$NON-NLS-1$
@@ -236,50 +191,6 @@
     public static VdcQueryReturnValue RunQuery(VdcQueryType queryType, 
VdcQueryParametersBase parameters) {
         logger.fine("Sync RunQuery is invoked, this is not supported! replace 
the call with the async method!"); //$NON-NLS-1$
         return null;
-    }
-
-    public static void RunPublicQuery(final VdcQueryType queryType,
-            final VdcQueryParametersBase parameters,
-            final IFrontendQueryAsyncCallback callback) {
-        initQueryParamsFilter(parameters);
-        dumpQueryDetails(queryType, parameters);
-        logger.finer("Frontend: Invoking async runPublicQuery."); //$NON-NLS-1$
-
-        GenericApiGWTServiceAsync service = 
GenericApiGWTServiceAsync.Util.getInstance();
-        service.RunPublicQuery(queryType, parameters, new 
AsyncCallback<VdcQueryReturnValue>() {
-            @Override
-            public void onFailure(Throwable caught) {
-                if (ignoreFailure(caught)) {
-                    return;
-                }
-                logger.log(Level.SEVERE, "Failed to execute RunPublicQuery: " 
+ caught, caught); //$NON-NLS-1$
-                FrontendQueryAsyncResult f = new 
FrontendQueryAsyncResult(queryType, parameters, null);
-                getEventsHandler().runQueryFailed(null);
-                failureEventHandler(caught);
-                callback.OnFailure(f);
-            }
-
-            @Override
-            public void onSuccess(VdcQueryReturnValue result) {
-                logger.finer("Succesful returned result from 
RunPublicQuery!"); //$NON-NLS-1$
-                FrontendQueryAsyncResult f = new 
FrontendQueryAsyncResult(queryType, parameters, result);
-
-                if (!result.getSucceeded()) {
-                    logger.log(Level.WARNING, "Failure while invoking 
ReturnQuery [" + result.getExceptionString() //$NON-NLS-1$
-                            + "]"); //$NON-NLS-1$
-                    if (getEventsHandler() != null) {
-                        ArrayList<VdcQueryReturnValue> failedResult = new 
ArrayList<VdcQueryReturnValue>();
-                        failedResult.add(result);
-                        getEventsHandler().runQueryFailed(failedResult);
-                        if 
(getEventsHandler().isRaiseErrorModalPanel(queryType))
-                            failureEventHandler(result.getExceptionString());
-                    }
-                    callback.OnFailure(f);
-                } else {
-                    callback.OnSuccess(f);
-                }
-            }
-        });
     }
 
     public static void RunPublicQuery(final VdcQueryType queryType,
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
index c932477..38f54d5 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
@@ -33,6 +33,7 @@
 import 
org.ovirt.engine.core.common.queries.MultilevelAdministrationByAdElementIdParameters;
 import org.ovirt.engine.core.common.queries.SearchParameters;
 import org.ovirt.engine.core.common.queries.ValueObjectMap;
+import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.common.users.VdcUser;
 import org.ovirt.engine.core.compat.Event;
@@ -68,10 +69,8 @@
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
 import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult;
 import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult;
-import org.ovirt.engine.ui.uicompat.FrontendQueryAsyncResult;
 import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback;
 import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback;
-import org.ovirt.engine.ui.uicompat.IFrontendQueryAsyncCallback;
 import org.ovirt.engine.ui.uicompat.ReversibleFlow;
 
 @SuppressWarnings("unused")
@@ -1614,31 +1613,31 @@
 
             Frontend.RunQuery(VdcQueryType.GetPermissionsByAdElementId,
                     new 
MultilevelAdministrationByAdElementIdParameters(vdcUser.getUserId()),
-                    new IFrontendQueryAsyncCallback() {
+                    new AsyncQuery(this, new INewAsyncCallback() {
+
                         @Override
-                        public void OnSuccess(FrontendQueryAsyncResult result) 
{
+                        public void OnSuccess(Object model, Object 
returnValue) {
+                            VdcQueryReturnValue response = 
(VdcQueryReturnValue) returnValue;
+                            if (response == null || !response.getSucceeded()) {
+                                hasAdminSystemPermission = false;
+                                
UpdateConfigureLocalStorageCommandAvailability1();
+                            } else {
+                                ArrayList<permissions> permissions =
+                                        (ArrayList<permissions>) 
response.getReturnValue();
+                                for (permissions permission : permissions) {
 
-                            ArrayList<permissions> permissions =
-                                    (ArrayList<permissions>) 
result.getReturnValue().getReturnValue();
-                            for (permissions permission : permissions) {
-
-                                if (permission.getObjectType() == 
VdcObjectType.System
-                                        && permission.getRoleType() == 
RoleType.ADMIN) {
-                                    hasAdminSystemPermission = true;
-                                    break;
+                                    if (permission.getObjectType() == 
VdcObjectType.System
+                                            && permission.getRoleType() == 
RoleType.ADMIN) {
+                                        hasAdminSystemPermission = true;
+                                        break;
+                                    }
                                 }
+
+                                
UpdateConfigureLocalStorageCommandAvailability1();
                             }
 
-                            UpdateConfigureLocalStorageCommandAvailability1();
                         }
-
-                        @Override
-                        public void OnFailure(FrontendQueryAsyncResult result) 
{
-
-                            hasAdminSystemPermission = false;
-                            UpdateConfigureLocalStorageCommandAvailability1();
-                        }
-                    });
+                    }, true));
         } else {
             UpdateConfigureLocalStorageCommandAvailability1();
         }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
index 0a5ebef..ab497c4 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
@@ -11,6 +11,7 @@
 import org.ovirt.engine.core.common.mode.ApplicationMode;
 import org.ovirt.engine.core.common.queries.GetNewVdsFenceStatusParameters;
 import org.ovirt.engine.core.common.queries.ValueObjectMap;
+import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Event;
 import org.ovirt.engine.core.compat.EventArgs;
@@ -37,8 +38,6 @@
 import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation;
 import org.ovirt.engine.ui.uicompat.Constants;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
-import org.ovirt.engine.ui.uicompat.FrontendQueryAsyncResult;
-import org.ovirt.engine.ui.uicompat.IFrontendQueryAsyncCallback;
 
 @SuppressWarnings("unused")
 public class HostModel extends Model
@@ -772,36 +771,36 @@
                 .getValue() : NGuid.Empty);
         param.setFencingOptions(new ValueObjectMap(getPmOptionsMap(), false));
 
-        Frontend.RunQuery(VdcQueryType.GetNewVdsFenceStatus, param, new 
IFrontendQueryAsyncCallback() {
+        Frontend.RunQuery(VdcQueryType.GetNewVdsFenceStatus, param, new 
AsyncQuery(this, new INewAsyncCallback() {
 
             @Override
-            public void OnSuccess(FrontendQueryAsyncResult result) {
-                if (result != null && result.getReturnValue() != null
-                        && result.getReturnValue().getReturnValue() != null) {
-                    FenceStatusReturnValue fenceStatusReturnValue =
-                            (FenceStatusReturnValue) 
result.getReturnValue().getReturnValue();
-                    String message = fenceStatusReturnValue.toString();
+            public void OnSuccess(Object model, Object returnValue) {
+                VdcQueryReturnValue response = (VdcQueryReturnValue) 
returnValue;
+                if (response == null || !response.getSucceeded()) {
+                    String message;
+                    if (response != null && response.getReturnValue() != null) 
{
+                        FenceStatusReturnValue fenceStatusReturnValue =
+                                (FenceStatusReturnValue) 
response.getReturnValue();
+                        message = fenceStatusReturnValue.toString();
+                    } else {
+                        message = 
ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
+                    }
                     setMessage(message);
                     getTestCommand().setIsExecutionAllowed(true);
-                }
-            }
-
-            @Override
-            public void OnFailure(FrontendQueryAsyncResult result) {
-                String message;
-                if (result != null && result.getReturnValue() != null
-                        && result.getReturnValue().getReturnValue() != null) {
-                    FenceStatusReturnValue fenceStatusReturnValue =
-                            (FenceStatusReturnValue) 
result.getReturnValue().getReturnValue();
-                    message = fenceStatusReturnValue.toString();
                 } else {
-                    message = 
ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
-                }
-                setMessage(message);
-                getTestCommand().setIsExecutionAllowed(true);
 
+                    if (response != null && response.getReturnValue() != null) 
{
+                        FenceStatusReturnValue fenceStatusReturnValue =
+                                (FenceStatusReturnValue) 
response.getReturnValue();
+                        String message = fenceStatusReturnValue.toString();
+                        setMessage(message);
+                        getTestCommand().setIsExecutionAllowed(true);
+                    }
+
+                }
             }
-        });
+        }
+                , true));
     }
 
     private void ValidatePmModels()
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IFrontendQueryAsyncCallback.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IFrontendQueryAsyncCallback.java
deleted file mode 100644
index 85db6c9..0000000
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IFrontendQueryAsyncCallback.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.ovirt.engine.ui.uicompat;
-
-public interface IFrontendQueryAsyncCallback {
-       void OnSuccess(FrontendQueryAsyncResult result);
-       void OnFailure(FrontendQueryAsyncResult result);
-}


--
To view, visit http://gerrit.ovirt.org/9553
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia306d5009f5e66d5203e5d9ad8135ae44fb65b3b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to