Search in sources :

Example 11 with GlobalConfig

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

the class Connection method setCredentialsParams.

protected void setCredentialsParams(AbstractClientCredentials credentials, Map<String, Object> loginParams) {
    credentials.setClientInfo(makeClientInfo());
    credentials.setClientType(ClientType.DESKTOP);
    Optional<InetAddress> address = Optional.empty();
    try {
        address = Optional.ofNullable(InetAddress.getLocalHost());
    } catch (UnknownHostException e) {
        log.warn("Unable to obtain local IP address", e);
    }
    if (address.isPresent()) {
        credentials.setIpAddress(address.get().getHostAddress());
        credentials.setHostName(address.get().getHostName());
    }
    credentials.setParams(loginParams);
    Configuration configuration = AppBeans.get(Configuration.class);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    if (!globalConfig.getLocaleSelectVisible()) {
        credentials.setOverrideLocale(false);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) InetAddress(java.net.InetAddress)

Example 12 with GlobalConfig

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

the class ServerInfo method getServerId.

@Override
public String getServerId() {
    if (serverId == null) {
        GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
        serverId = globalConfig.getWebHostName() + ":" + globalConfig.getWebPort() + "/" + globalConfig.getWebContextName();
    }
    return serverId;
}
Also used : GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 13 with GlobalConfig

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

the class DbUpdaterEngineTest method setUp.

@SuppressWarnings("ResultOfMethodCallIgnored")
@BeforeEach
public void setUp() throws Exception {
    GlobalConfig config = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class);
    dbmsDir = new File(config.getTempDir(), "db. dir");
    if (dbmsDir.exists()) {
        FileUtils.deleteDirectory(dbmsDir);
    }
    dbmsDir.mkdirs();
    dbmsWebInfDir = new File(config.getTempDir(), "WEB-INF/db");
    if (dbmsWebInfDir.exists()) {
        FileUtils.deleteDirectory(dbmsWebInfDir);
    }
    dbmsWebInfDir.mkdirs();
    File dir;
    File file;
    // Init scripts
    dir = new File(dbmsWebInfDir, "10-cuba/init/postgres");
    dir.mkdirs();
    file = new File(dir, "create-db.sql");
    file.createNewFile();
    dir = new File(dbmsDir, "10-cuba/init/mssql");
    dir.mkdirs();
    file = new File(dir, "create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    dir = new File(dbmsDir, "10-cuba/init/mssql-2012");
    dir.mkdirs();
    file = new File(dir, "create-db.sql");
    file.createNewFile();
    mssql2012InitFiles.add(file);
    dir = new File(dbmsDir, "10-cuba/init_addstore/mssql");
    dir.mkdirs();
    file = new File(dir, "create-db.sql");
    file.createNewFile();
    mssqlInitAddStoreFiles.add(file);
    dir = new File(dbmsDir, "50-app/init/mssql");
    dir.mkdirs();
    file = new File(dir, "10.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    file = new File(dir, "20.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    file = new File(dir, "30.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    dir = new File(dbmsDir, "50-app/init/mssql-2012");
    dir.mkdirs();
    file = new File(dir, "30.create-db.sql");
    file.createNewFile();
    mssql2012InitFiles.add(file);
    file = new File(dir, "40.create-db.sql");
    file.createNewFile();
    mssql2012InitFiles.add(file);
    dir = new File(dbmsDir, "50-app1/init/mssql");
    dir.mkdirs();
    file = new File(dir, "10.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    file = new File(dir, "20.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    file = new File(dir, "30.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    dir = new File(dbmsDir, "100-app2/init/mssql");
    dir.mkdirs();
    file = new File(dir, "10.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    file = new File(dir, "20.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    file = new File(dir, "30.create-db.sql");
    file.createNewFile();
    mssqlInitFiles.add(file);
    mssql2012InitFiles.add(file);
    // Update scripts
    dir = new File(dbmsDir, "10-cuba/update/mssql/13");
    dir.mkdirs();
    file = new File(dir, "cuba-update-1.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    dir = new File(dbmsDir, "10-cuba/update/mssql/14");
    dir.mkdirs();
    file = new File(dir, "cuba-update-2.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    dir = new File(dbmsDir, "50-app/update/mssql/14");
    dir.mkdirs();
    file = new File(dir, "app-update-0.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    file = new File(dir, "app-update-1.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    dir = new File(dbmsDir, "50-app/update/mssql-2012/14");
    dir.mkdirs();
    file = new File(dir, "app-update-1.sql");
    file.createNewFile();
    mssql2012UpdateFiles.add(file);
    file = new File(dir, "app-update-2.sql");
    file.createNewFile();
    mssql2012UpdateFiles.add(file);
    dir = new File(dbmsDir, "50-app1/update/mssql/14");
    dir.mkdirs();
    file = new File(dir, "app1-update-0.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    file = new File(dir, "app1-update-1.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    dir = new File(dbmsDir, "100-app2/update/mssql/14");
    dir.mkdirs();
    file = new File(dir, "app2-update-0.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    file = new File(dir, "app2-update-1.sql");
    file.createNewFile();
    mssqlUpdateFiles.add(file);
    mssql2012UpdateFiles.add(file);
    dir = new File(dbmsDir, "100-app2/update_addstore/mssql");
    dir.mkdirs();
    file = new File(dir, "app-update-1.sql");
    file.createNewFile();
    mssqlUpdateAddStoreFiles.add(file);
    file = new File(dir, "app-update-2.sql");
    file.createNewFile();
    mssqlUpdateAddStoreFiles.add(file);
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with GlobalConfig

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

the class ControllerUtils method getControllerURL.

public static String getControllerURL(String mapping) {
    if (mapping == null)
        throw new IllegalArgumentException("Mapping cannot be null");
    Configuration configuration = AppBeans.get(Configuration.NAME);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    StringBuilder sb = new StringBuilder(globalConfig.getWebAppUrl()).append(getControllerPrefix());
    if (!mapping.startsWith("/")) {
        sb.append("/");
    }
    sb.append(mapping);
    return sb.toString();
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 15 with GlobalConfig

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

the class SiteSettings method composeFullRelativePath.

/**
 * Basically this method prepends webapp's prefix to the path
 *
 * @param path path relative to the root of webapp
 * @return Full relative path on server
 */
public String composeFullRelativePath(String path) {
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    String webAppPrefix = "/".concat(globalConfig.getWebContextName().intern());
    return path.startsWith("/") ? webAppPrefix.concat(path) : webAppPrefix.concat("/").concat(path);
}
Also used : 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