Search in sources :

Example 6 with GlobalConfig

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

the class ByteArrayDataProvider method saveToTempStorage.

protected File saveToTempStorage(byte[] data) {
    UUID uuid = UuidProvider.createUuid();
    GlobalConfig config = getConfiguration().getConfig(GlobalConfig.class);
    String tempDir = config.getTempDir();
    File dir = new File(tempDir);
    File file = new File(dir, uuid.toString());
    try {
        FileUtils.writeByteArrayToFile(file, data);
    } catch (IOException e) {
        throw new RuntimeException("Unable to write byte data to temp file", e);
    }
    log.debug("Stored {} bytes of data to temporary file {}", data.length, file.getAbsolutePath());
    return file;
}
Also used : GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) UUID(java.util.UUID)

Example 7 with GlobalConfig

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

the class AppFolderEditWindow method create.

public static FolderEditWindow create(boolean isAppFolder, boolean adding, Folder folder, Presentations presentations, Runnable commitHandler) {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    String className = isAppFolder ? globalConfig.getAppFolderEditWindowClassName() : globalConfig.getFolderEditWindowClassName();
    if (className != null) {
        Class<FolderEditWindow> aClass = ReflectionHelper.getClass(className);
        try {
            Constructor constructor = aClass.getConstructor(boolean.class, Folder.class, Presentations.class, Runnable.class);
            return (FolderEditWindow) constructor.newInstance(adding, folder, presentations, commitHandler);
        } catch (Exception e) {
            throw new RuntimeException("Unable to create FolderEditWindow", e);
        }
    } else
        return isAppFolder ? new AppFolderEditWindow(adding, (AppFolder) folder, presentations, commitHandler) : new FolderEditWindow(adding, folder, presentations, commitHandler);
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) Constructor(java.lang.reflect.Constructor) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 8 with GlobalConfig

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

the class ExternalOAuthTokenGranter 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 9 with GlobalConfig

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

the class PortalConnection method getSessionParams.

protected Map<String, Object> getSessionParams(String ipAddress, String clientInfo) {
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    String serverInfo = "Portal (" + globalConfig.getWebHostName() + ":" + globalConfig.getWebPort() + "/" + globalConfig.getWebContextName() + ") ";
    return ParamsMap.of(ClientType.class.getName(), AppContext.getProperty("cuba.clientType"), SessionParams.IP_ADDRESS.getId(), ipAddress, SessionParams.CLIENT_INFO.getId(), serverInfo + clientInfo);
}
Also used : ClientType(com.haulmont.cuba.core.global.ClientType) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 10 with GlobalConfig

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

the class RemotingServlet method checkConfiguration.

/**
 * Check correctness of some configuration parameters and log the warning if necessary.
 */
protected void checkConfiguration(HttpServletRequest request) {
    if (!checkCompleted) {
        GlobalConfig config = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class);
        if (config.getLogIncorrectWebAppPropertiesEnabled()) {
            StringBuilder sb = new StringBuilder();
            if (!request.getServerName().equals(config.getWebHostName())) {
                sb.append("***** cuba.webHostName=").append(config.getWebHostName()).append(", actual=").append(request.getServerName()).append("\n");
            }
            if (request.getServerPort() != Integer.parseInt(config.getWebPort())) {
                sb.append("***** cuba.webPort=").append(config.getWebPort()).append(", actual=").append(request.getServerPort()).append("\n");
            }
            String contextPath = request.getContextPath();
            if (contextPath.startsWith("/"))
                contextPath = contextPath.substring(1);
            if (!contextPath.equals(config.getWebContextName())) {
                sb.append("***** cuba.webContextName=").append(config.getWebContextName()).append(", actual=").append(contextPath).append("\n");
            }
            if (sb.length() > 0) {
                sb.insert(0, "\n*****\n");
                sb.append("*****");
                log.warn(" Invalid configuration parameters that may cause problems:" + sb.toString());
            }
        }
        checkCompleted = true;
    }
}
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