Search in sources :

Example 26 with QueryParametersBase

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

the class BackendApiResource method setAuthenticatedUser.

/**
 * Set a link to the user of the current session
 * (the 'authenticated user') in the API object.
 * This link enables users a convenient way to see
 * which is the logged-in user, using the system.
 */
private void setAuthenticatedUser(Api api) {
    QueryReturnValue returnValue = runQuery(QueryType.GetUserBySessionId, new QueryParametersBase());
    DbUser authenticatedUser = (DbUser) returnValue.getReturnValue();
    User user = new User();
    user.setId(authenticatedUser.getId().toString());
    LinkHelper.addLinks(user);
    api.setAuthenticatedUser(user);
    api.setEffectiveUser(user);
// currently the authenticated and effective users are the same one,
// but if and when impersonation is introduced, they may be different.
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) User(org.ovirt.engine.api.model.User) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 27 with QueryParametersBase

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

the class BackendUsersResource method add.

@Override
public Response add(User user) {
    validateParameters(user, "userName");
    List<String> authzProvidersNames = getBackendCollection(String.class, QueryType.GetDomainList, new QueryParametersBase());
    if (AuthzUtils.getAuthzNameFromEntityName(user.getUserName(), authzProvidersNames) == null) {
        // user-name may contain the domain (e.g: oliel@xxx.yyy)
        validateParameters(user, "domain.id|name");
    }
    String domain = getAuthzProviderName(user, authzProvidersNames);
    DirectoryUser directoryUser = findDirectoryUser(domain, user);
    if (directoryUser == null) {
        return Response.status(Status.BAD_REQUEST).entity("No such user: " + user.getUserName() + " in domain " + domain).build();
    }
    AddUserParameters parameters = new AddUserParameters(new DbUser(directoryUser));
    QueryIdResolver<Guid> resolver = new QueryIdResolver<>(QueryType.GetDbUserByUserId, IdQueryParameters.class);
    return performCreate(ActionType.AddUser, parameters, resolver, BaseResource.class);
}
Also used : DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 28 with QueryParametersBase

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

the class AsyncDataProvider method getAAAProfilesListViaPublic.

public void getAAAProfilesListViaPublic(AsyncQuery<List<String>> aQuery, boolean passwordBasedOnly) {
    convertAAAProfilesResult(aQuery, passwordBasedOnly);
    Frontend.getInstance().runPublicQuery(QueryType.GetAAAProfileList, new QueryParametersBase(), aQuery);
}
Also used : QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StorageServerConnectionQueryParametersBase(org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)

Example 29 with QueryParametersBase

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

the class AsyncDataProvider method getClusterListByService.

public void getClusterListByService(AsyncQuery<List<Cluster>> aQuery, final boolean supportsVirtService, final boolean supportsGlusterService) {
    aQuery.converterCallback = source -> {
        if (source != null) {
            ArrayList<Cluster> list = getClusterByServiceList((ArrayList<Cluster>) source, supportsVirtService, supportsGlusterService);
            Collections.sort(list, new NameableComparator());
            return list;
        }
        return new ArrayList<>();
    };
    Frontend.getInstance().runQuery(QueryType.GetAllClusters, new QueryParametersBase(), aQuery);
}
Also used : NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StorageServerConnectionQueryParametersBase(org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)

Example 30 with QueryParametersBase

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

the class AsyncDataProvider method getDefaultConfigurationVersion.

private void getDefaultConfigurationVersion(final LoginModel loginModel) {
    AsyncQuery<QueryReturnValue> callback = new AsyncQuery<>(returnValue -> {
        if (returnValue != null) {
            _defaultConfigurationVersion = ((QueryReturnValue) returnValue).getReturnValue();
        } else {
            _defaultConfigurationVersion = GENERAL;
        }
        loginModel.getLoggedInEvent().raise(loginModel, EventArgs.EMPTY);
    });
    callback.setHandleFailure(true);
    Frontend.getInstance().runQuery(QueryType.GetDefaultConfigurationVersion, new QueryParametersBase(), callback);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StorageServerConnectionQueryParametersBase(org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)

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