Search in sources :

Example 1 with GlobalConfig

use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.

the class CubaUserAuthenticationProvider method makeClientInfo.

protected String makeClientInfo(String userAgent) {
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    // noinspection UnnecessaryLocalVariable
    String serverInfo = String.format("REST API (%s:%s/%s) %s", globalConfig.getWebHostName(), globalConfig.getWebPort(), globalConfig.getWebContextName(), StringUtils.trimToEmpty(userAgent));
    return serverInfo;
}
Also used : GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 2 with GlobalConfig

use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.

the class RestAuthUtils method extractLocaleFromRequestHeader.

/**
 * Method extracts locale information from the Accept-Language header. If no such header is specified or the
 * passed locale is not among application available locales, then null is returned
 */
@Nullable
public Locale extractLocaleFromRequestHeader(HttpServletRequest request) {
    Locale locale = null;
    if (!Strings.isNullOrEmpty(request.getHeader(HttpHeaders.ACCEPT_LANGUAGE))) {
        Locale requestLocale = request.getLocale();
        GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
        Map<String, Locale> availableLocales = globalConfig.getAvailableLocales();
        if (availableLocales.values().contains(requestLocale)) {
            locale = requestLocale;
        } else {
            log.warn("Locale {} passed in the Accept-Language header is not supported by the application. It was ignored.");
        }
    }
    return locale;
}
Also used : Locale(java.util.Locale) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) Nullable(javax.annotation.Nullable)

Example 3 with GlobalConfig

use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.

the class JmxLogControl method getLogFileLink.

@Override
public String getLogFileLink(String fileName) throws LogControlException {
    // check log file exists
    logControl.getLogFile(fileName);
    Configuration configuration = AppBeans.get(Configuration.NAME);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    String encodedFileName = URLEncodeUtils.encodeUtf8(fileName);
    return globalConfig.getDispatcherBaseUrl() + "/log/" + encodedFileName;
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 4 with GlobalConfig

use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.

the class ServerInfo method setConfiguration.

@Inject
public void setConfiguration(Configuration configuration) {
    this.configuration = configuration;
    InputStream stream = getClass().getResourceAsStream(CUBA_RELEASE_NUMBER_PATH);
    if (stream != null) {
        try {
            releaseNumber = IOUtils.toString(stream, StandardCharsets.UTF_8);
        } catch (IOException e) {
            log.warn("Unable to read release number", e);
        }
    }
    stream = getClass().getResourceAsStream(CUBA_RELEASE_TIMESTAMP_PATH);
    if (stream != null) {
        try {
            releaseTimestamp = IOUtils.toString(stream, StandardCharsets.UTF_8);
        } catch (IOException e) {
            log.warn("Unable to read release timestamp", e);
        }
    }
    globalConfig = configuration.getConfig(GlobalConfig.class);
}
Also used : InputStream(java.io.InputStream) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) IOException(java.io.IOException) Inject(javax.inject.Inject)

Example 5 with GlobalConfig

use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.

the class NodeIdentifierImpl method getNodeName.

@Override
public String getNodeName() {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    return globalConfig.getWebHostName() + ":" + globalConfig.getWebPort();
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Aggregations

GlobalConfig (com.haulmont.cuba.core.global.GlobalConfig)17 Configuration (com.haulmont.cuba.core.global.Configuration)7 Locale (java.util.Locale)2 FormatStrings (com.haulmont.chile.core.datatypes.FormatStrings)1 ClientType (com.haulmont.cuba.core.global.ClientType)1 ThemeConstantsRepository (com.haulmont.cuba.gui.theme.ThemeConstantsRepository)1 WebConfig (com.haulmont.cuba.web.WebConfig)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Constructor (java.lang.reflect.Constructor)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Properties (java.util.Properties)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1