Search in sources :

Example 61 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class GetSessionUser method runQuery.

private boolean runQuery(HttpServletResponse response, String sessionID) {
    boolean returnValue = false;
    log.debug("Calling ValidateSession query");
    QueryReturnValue queryReturnValue = backend.runInternalQuery(QueryType.ValidateSession, new QueryParametersBase(sessionID));
    if (queryReturnValue != null) {
        returnValue = queryReturnValue.getSucceeded();
        if (returnValue) {
            DbUser user = queryReturnValue.getReturnValue();
            // We get the user name only in case the validation succeeded, and the user is an administrator
            if (user.isAdmin()) {
                log.debug("Getting user name");
                printUPNToResponse(response, getUPN(user));
            } else {
                log.error("User '{}' is not authorized to perform operation", user.getLoginName());
                returnValue = false;
            }
        }
    } else {
        log.error("Got NULL from backend.RunQuery");
    }
    return returnValue;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 62 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class HealthStatus method runQuery.

private boolean runQuery(PrintWriter out) {
    boolean fReturn = false;
    try {
        log.debug("Calling CheckDBConnection query");
        QueryParametersBase params = new QueryParametersBase();
        QueryReturnValue v = backend.runInternalQuery(QueryType.CheckDBConnection, params);
        if (v != null) {
            fReturn = v.getSucceeded();
            out.print(fReturn ? "DB Up!" : "DB Down!");
        } else {
            log.error("Got NULL from backend.RunQuery!");
        }
    } catch (Throwable t) {
        String msg = "Unable to contact Database!";
        if (backend == null) {
            msg = "Unable to contact Backend!";
        }
        out.print(msg);
        log.error(msg, t);
        fReturn = false;
    }
    return fReturn;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase)

Example 63 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method testMissingXsrfToken.

@SuppressWarnings("unchecked")
@Test
public void testMissingXsrfToken() {
    // Remove token so there should be a request for it.
    mockXsrfRpcRequestBuilder.setXsrfToken(null);
    QueryParametersBase testParameters = new QueryParametersBase();
    final List<VdcOperation<QueryType, QueryParametersBase>> operationList = new ArrayList<>();
    final VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameters, null);
    operationList.add(testOperation);
    testProvider.transmitOperation(testOperation);
    verify(mockXsrfService).getNewXsrfToken((AsyncCallback<XsrfToken>) any());
}
Also used : ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) XsrfToken(com.google.gwt.user.client.rpc.XsrfToken) Test(org.junit.Test)

Example 64 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_multipleQuery_different_callback_failure.

@Test
public void testTransmitOperationList_multipleQuery_different_callback_failure() {
    List<VdcOperation<?, ?>> testList = new ArrayList<>();
    List<VdcOperation<?, ?>> operation1List = new ArrayList<>();
    List<VdcOperation<?, ?>> operation2List = new ArrayList<>();
    QueryParametersBase testParameters = new QueryParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList1);
    VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList2);
    testList.add(testOperation1);
    testList.add(testOperation2);
    operation1List.add(testOperation1);
    operation2List.add(testOperation2);
    List<QueryParametersBase> testParameterList = createQueryParameterList(testParameters, 2);
    List<QueryType> testQueryList = createQueryList(QueryType.Search, 2);
    testProvider.transmitOperationList(testList);
    verify(mockService).runMultipleQueries(eq((ArrayList<QueryType>) testQueryList), (ArrayList<QueryParametersBase>) eq(testParameterList), queryCallbackList.capture());
    // $NON-NLS-1$
    Exception testException = new Exception("This is an exception");
    queryCallbackList.getValue().onFailure(testException);
    verify(mockOperationCallbackList1).onFailure(eq(operation1List), eq(testException));
    verify(mockOperationCallbackList2).onFailure(eq(operation2List), eq(testException));
}
Also used : ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 65 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_multipleQuery_different_callback_success.

@Test
public void testTransmitOperationList_multipleQuery_different_callback_success() {
    List<VdcOperation<?, ?>> testList = new ArrayList<>();
    List<VdcOperation<?, ?>> operation1List = new ArrayList<>();
    List<VdcOperation<?, ?>> operation2List = new ArrayList<>();
    QueryParametersBase testParameters = new QueryParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList1);
    VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList2);
    testList.add(testOperation1);
    testList.add(testOperation2);
    operation1List.add(testOperation1);
    operation2List.add(testOperation2);
    List<QueryParametersBase> testParameterList = createQueryParameterList(testParameters, 2);
    List<QueryType> testQueryList = createQueryList(QueryType.Search, 2);
    testProvider.transmitOperationList(testList);
    QueryReturnValue returnValue = new QueryReturnValue();
    List<QueryReturnValue> resultList = createQueryResultList(returnValue, 2);
    List<QueryReturnValue> return1List = createQueryResultList(returnValue, 1);
    List<QueryReturnValue> return2List = createQueryResultList(returnValue, 1);
    verify(mockService).runMultipleQueries(eq((ArrayList<QueryType>) testQueryList), (ArrayList<QueryParametersBase>) eq(testParameterList), queryCallbackList.capture());
    queryCallbackList.getValue().onSuccess((ArrayList<QueryReturnValue>) resultList);
    verify(mockOperationCallbackList1).onSuccess(eq(operation1List), eq(return1List));
    verify(mockOperationCallbackList2).onSuccess(eq(operation2List), eq(return2List));
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Aggregations

QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)89 ArrayList (java.util.ArrayList)41 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)40 QueryType (org.ovirt.engine.core.common.queries.QueryType)37 Test (org.junit.Test)33 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)22 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)18 List (java.util.List)15 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)13 HashMap (java.util.HashMap)11 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 HashSet (java.util.HashSet)7 Map (java.util.Map)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Frontend (org.ovirt.engine.ui.frontend.Frontend)6 Collection (java.util.Collection)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)5 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5