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