Search in sources :

Example 41 with QueryParametersBase

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

the class RemoveQosModel method setMessage.

private void setMessage() {
    ArrayList<QueryParametersBase> parameters = new ArrayList<>();
    ArrayList<QueryType> queryTypes = new ArrayList<>();
    for (T qos : sourceListModel.getSelectedItems()) {
        QueryParametersBase parameter = new IdQueryParameters(qos.getId());
        parameters.add(parameter);
        queryTypes.add(getUsingEntitiesByQosIdQueryType());
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> handleSetMessageQueryResult(result));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 42 with QueryParametersBase

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

the class RemoveNetworkQoSModel method setMessage.

private void setMessage() {
    ArrayList<QueryParametersBase> parameters = new ArrayList<>();
    ArrayList<QueryType> queryTypes = new ArrayList<>();
    for (Object networkQoS : sourceListModel.getSelectedItems()) {
        QueryParametersBase parameter = new IdQueryParameters(((NetworkQoS) networkQoS).getId());
        parameters.add(parameter);
        queryTypes.add(QueryType.GetVnicProfilesByNetworkQosId);
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> {
        ArrayList<VnicProfileView> vnicProfiles = new ArrayList<>();
        setHelpTag(HelpTag.remove_network_qos);
        // $NON-NLS-1$
        setHashName("remove_network_qos");
        for (QueryReturnValue returnValue : result.getReturnValues()) {
            vnicProfiles.addAll((ArrayList<VnicProfileView>) returnValue.getReturnValue());
        }
        if (vnicProfiles.isEmpty()) {
            ArrayList<String> list = new ArrayList<>();
            for (Object item : sourceListModel.getSelectedItems()) {
                NetworkQoS i = (NetworkQoS) item;
                list.add(i.getName());
            }
            setItems(list);
        } else {
            setMessage(ConstantsManager.getInstance().getMessages().removeNetworkQoSMessage(vnicProfiles.size()));
            ArrayList<String> list = new ArrayList<>();
            for (VnicProfileView item : vnicProfiles) {
                list.add(item.getName());
            }
            setItems(list);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 43 with QueryParametersBase

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

the class ImportVmFromExternalProviderModel method initQuotaForStorageDomains.

private void initQuotaForStorageDomains() {
    List<QueryType> queryTypeList = new ArrayList<>();
    List<QueryParametersBase> queryParamsList = new ArrayList<>();
    for (StorageDomain storage : getStorage().getItems()) {
        queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
        queryParamsList.add(new IdQueryParameters(storage.getId()));
    }
    storageQuotaMap = new HashMap<>();
    Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
        Iterator<QueryReturnValue> returnValuesIter = result.getReturnValues().iterator();
        Iterator<StorageDomain> domainsIter = getStorage().getItems().iterator();
        boolean noQuota = true;
        while (domainsIter.hasNext()) {
            ArrayList<Quota> quotaList = returnValuesIter.next().getReturnValue();
            noQuota = noQuota && quotaList.isEmpty();
            storageQuotaMap.put(domainsIter.next().getId(), quotaList);
        }
        if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
            showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
        }
        initDisksStorageDomainsList();
    });
}
Also used : ArrayList(java.util.ArrayList) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 44 with QueryParametersBase

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

the class FiltersHelper method isSessionValid.

public static boolean isSessionValid(String session) {
    try {
        InitialContext ctx = null;
        try {
            ctx = new InitialContext();
            QueryReturnValue returnValue = FiltersHelper.getBackend(ctx).runPublicQuery(QueryType.ValidateSession, new QueryParametersBase(session));
            return returnValue.getSucceeded();
        } finally {
            if (ctx != null) {
                ctx.close();
            }
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) InitialContext(javax.naming.InitialContext) IOException(java.io.IOException) NamingException(javax.naming.NamingException)

Example 45 with QueryParametersBase

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

the class SsoLogoutServlet method service.

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.debug("Entered SsoLogoutServlet");
    String token = null;
    try {
        String engineSessionId = (String) request.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY);
        if (StringUtils.isEmpty(engineSessionId) && request.getSession(false) != null) {
            engineSessionId = (String) request.getSession(false).getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY);
        }
        if (StringUtils.isNotEmpty(engineSessionId)) {
            InitialContext ctx = new InitialContext();
            try {
                QueryParametersBase params = new QueryParametersBase(engineSessionId);
                params.setFiltered(true);
                QueryReturnValue retValue = FiltersHelper.getBackend(ctx).runQuery(QueryType.GetEngineSessionIdToken, params);
                token = retValue.getReturnValue();
                FiltersHelper.getBackend(ctx).runAction(ActionType.LogoutSession, new ActionParametersBase(engineSessionId));
            } finally {
                ctx.close();
            }
        }
    } catch (Exception ex) {
        log.error("Unable to clear user session {}", ex.getMessage());
    }
    HttpSession session = request.getSession(false);
    if (session != null) {
        log.debug("Setting session attribute {}", FiltersHelper.Constants.LOGOUT_INPROGRESS);
        session.setAttribute(FiltersHelper.Constants.LOGOUT_INPROGRESS, true);
    }
    Map<String, Object> revokeResponse = SsoOAuthServiceUtils.revoke(token);
    String error_description = (String) revokeResponse.get("error_description");
    String error = (String) revokeResponse.get("error");
    if (StringUtils.isNotEmpty(error_description)) {
        log.error("Unable to logout user: {}", error_description);
    }
    String url = String.format("%s://%s:%s%s/oauth2-callback", request.getScheme(), FiltersHelper.getRedirectUriServerName(request.getServerName()), request.getServerPort(), EngineLocalConfig.getInstance().getProperty("ENGINE_URI"));
    String redirectUri = new URLBuilder(url).addParameter("error_description", StringUtils.defaultIfEmpty(error_description, "")).addParameter("error", StringUtils.defaultIfEmpty(error, "")).build();
    if (session != null) {
        log.debug("Invalidating existing session");
        session.invalidate();
    }
    log.debug("Redirecting to {}", redirectUri);
    response.sendRedirect(redirectUri);
    log.debug("Exiting SsoLogoutServlet");
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) HttpSession(javax.servlet.http.HttpSession) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) InitialContext(javax.naming.InitialContext) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) URLBuilder(org.ovirt.engine.core.uutils.net.URLBuilder)

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