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