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