Search in sources :

Example 21 with GetConfigurationValueParameters

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

the class AsyncDataProvider method getConfigurationValueBoolean.

public void getConfigurationValueBoolean(AsyncQuery<Boolean> aQuery, ConfigValues configVal) {
    aQuery.converterCallback = new DefaultValueConverter<>(Boolean.TRUE);
    getConfigFromCache(new GetConfigurationValueParameters(configVal, getDefaultConfigurationVersion()), aQuery);
}
Also used : GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters)

Example 22 with GetConfigurationValueParameters

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

the class AsyncDataProvider method getNumOfMonitorList.

public void getNumOfMonitorList(AsyncQuery<List<Integer>> aQuery) {
    aQuery.converterCallback = source -> {
        ArrayList<Integer> nums = new ArrayList<>();
        if (source != null) {
            Iterable numEnumerable = (Iterable) source;
            Iterator numIterator = numEnumerable.iterator();
            while (numIterator.hasNext()) {
                nums.add(Integer.parseInt(numIterator.next().toString()));
            }
        }
        return nums;
    };
    getConfigFromCache(new GetConfigurationValueParameters(ConfigValues.ValidNumOfMonitors, getDefaultConfigurationVersion()), aQuery);
}
Also used : GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 23 with GetConfigurationValueParameters

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

the class CurrentFilter method findApplicationMode.

private ApplicationMode findApplicationMode(String sessionId) {
    GetConfigurationValueParameters parameters = new GetConfigurationValueParameters(ConfigValues.ApplicationMode, ConfigCommon.defaultConfigurationVersion);
    parameters.setSessionId(sessionId);
    QueryReturnValue result = backend.runPublicQuery(QueryType.GetConfigurationValue, parameters);
    return ApplicationMode.from(result.getReturnValue());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters)

Example 24 with GetConfigurationValueParameters

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

the class WelcomeServlet method doGet.

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
    log.debug("Entered WelcomeServlet");
    String reauthenticate = (String) request.getSession(true).getAttribute(WelcomeUtils.REAUTHENTICATE);
    if (StringUtils.isEmpty(reauthenticate)) {
        Map<String, Object> deployedResponse = isSsoWebappDeployed();
        if (deployedResponse.containsKey(WelcomeUtils.ERROR_DESCRIPTION)) {
            request.getSession(true).setAttribute(WelcomeUtils.ERROR_DESCRIPTION, deployedResponse.get(WelcomeUtils.ERROR_DESCRIPTION));
            request.getSession(true).setAttribute(WelcomeUtils.ERROR, deployedResponse.get(WelcomeUtils.ERROR));
        }
    }
    String authCode = (String) request.getSession(true).getAttribute(WelcomeUtils.AUTH_CODE);
    String token = (String) request.getSession(true).getAttribute(WelcomeUtils.TOKEN);
    String errorDescription = (String) request.getSession(true).getAttribute(WelcomeUtils.ERROR_DESCRIPTION);
    if (StringUtils.isNotEmpty(token) && !isSessionValid(request, token)) {
        request.getSession(true).removeAttribute(WelcomeUtils.TOKEN);
        request.getSession(true).removeAttribute(WelcomeUtils.SSO_USER);
        request.getSession(true).removeAttribute(WelcomeUtils.CAPABILITY_CREDENTIALS_CHANGE);
        token = "";
    }
    if (authCode == null && StringUtils.isEmpty(errorDescription) && StringUtils.isEmpty(reauthenticate)) {
        if (StringUtils.isNotEmpty(request.getParameter(WelcomeUtils.ERROR)) && !WelcomeUtils.ERR_OVIRT_CODE_NOT_AUTHENTICATED.equals(request.getParameter(WelcomeUtils.ERROR))) {
            request.getSession(true).setAttribute(WelcomeUtils.ERROR_DESCRIPTION, request.getParameter(WelcomeUtils.ERROR_DESCRIPTION));
            request.getSession(true).setAttribute(WelcomeUtils.ERROR, request.getParameter(WelcomeUtils.ERROR));
        }
        String url = WelcomeUtils.getLoginUrl(engineUri, identityScope);
        log.debug("redirecting to {}", url);
        response.sendRedirect(url);
    } else {
        request.getSession(true).removeAttribute(WelcomeUtils.REAUTHENTICATE);
        log.debug("Displaying Welcome Page");
        try {
            setUserNameForMenu(request, token);
        } catch (Exception ex) {
            log.debug("Unable to set request attributed for user menu", ex);
            log.error("Unable to set request attributed for user menu: {}", ex.getMessage());
        }
        request.setAttribute(LOCALE_KEYS, UnsupportedLocaleHelper.getDisplayedLocales(LocaleFilter.getLocaleKeys()));
        String oVirtVersion = backend.runPublicQuery(QueryType.GetConfigurationValue, new GetConfigurationValueParameters(ConfigValues.ProductRPMVersion, ConfigCommon.defaultConfigurationVersion)).getReturnValue();
        request.setAttribute("sso_credential_change_url", getCredentialsChangeUrl(request));
        request.setAttribute(VERSION, oVirtVersion != null ? oVirtVersion : "myVersion");
        request.setAttribute(SECTIONS, brandingManager.getWelcomeSections((Locale) request.getAttribute(LocaleFilter.LOCALE)));
        log.debug("Including to ovirt-engine.jsp");
        RequestDispatcher dispatcher = request.getRequestDispatcher(WelcomeUtils.WELCOME_PAGE_JSP_URI);
        response.setContentType("text/html;charset=UTF-8");
        if (dispatcher != null) {
            dispatcher.include(request, response);
        }
    }
    log.debug("Exiting WelcomeServlet");
}
Also used : Locale(java.util.Locale) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) ServletException(javax.servlet.ServletException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 25 with GetConfigurationValueParameters

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

the class CORSSupportFilter method getBackendParameter.

private Object getBackendParameter(final ConfigValues key) throws ServletException {
    final GetConfigurationValueParameters parameters = new GetConfigurationValueParameters();
    parameters.setConfigValue(key);
    parameters.setVersion(ConfigCommon.defaultConfigurationVersion);
    QueryReturnValue value = backend.runPublicQuery(QueryType.GetConfigurationValue, parameters);
    if (!value.getSucceeded()) {
        throw new ServletException("Can't get value of backend parameter \"" + key + "\".");
    }
    return value.getReturnValue();
}
Also used : ServletException(javax.servlet.ServletException) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters)

Aggregations

GetConfigurationValueParameters (org.ovirt.engine.core.common.queries.GetConfigurationValueParameters)25 ArrayList (java.util.ArrayList)4 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)3 ServletException (javax.servlet.ServletException)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Locale (java.util.Locale)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 CreateBrickParameters (org.ovirt.engine.core.common.action.gluster.CreateBrickParameters)1 SyncGlusterStorageDevicesParameter (org.ovirt.engine.core.common.action.gluster.SyncGlusterStorageDevicesParameter)1 RaidType (org.ovirt.engine.core.common.businessentities.RaidType)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)1 StorageDevice (org.ovirt.engine.core.common.businessentities.gluster.StorageDevice)1