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;
}
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;
}
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());
}
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));
}
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));
}
Aggregations