This commit is contained in:
Serge Rider
2021-11-30 18:57:58 +03:00
parent a88905809c
commit 91e16eacb1
2 changed files with 12 additions and 12 deletions
@@ -22,7 +22,8 @@ import org.jkiss.dbeaver.model.DBPDataSourceConfigurationStorage;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -59,11 +60,11 @@ public class SampleDataSourceConfigurationStorage implements DBPDataSourceConfig
@Override
public List<? extends DBPDataSourceContainer> loadDataSources(DBPDataSourceRegistry registry, Map<String, Object> options) throws DBException {
File metadataFolder = registry.getProject().getMetadataFolder(false);
if (metadataFolder.exists()) {
File sampleConfigFile = new File(metadataFolder, SAMPLE_CONFIG_NAME);
if (sampleConfigFile.exists()) {
log.debug("Loading provided connections from [" + sampleConfigFile.getAbsolutePath() + "]");
Path metadataFolder = registry.getProject().getMetadataFolder(false);
if (Files.exists(metadataFolder)) {
Path sampleConfigFile = metadataFolder.resolve(SAMPLE_CONFIG_NAME);
if (Files.exists(sampleConfigFile)) {
log.debug("Loading provided connections from [" + sampleConfigFile.toAbsolutePath() + "]");
List<? extends DBPDataSourceContainer> dsList = registry.loadDataSourcesFromFile(this, sampleConfigFile);
// for (DBPDataSourceContainer ds : dsList) {
// log.debug("\tProvided connection: " + ds.getName());
@@ -65,6 +65,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@@ -116,9 +117,9 @@ public class WebSession implements DBASession, DBAAuthCredentialsProvider, IAdap
private final SessionContextImpl sessionAuthContext;
@NotNull
public static File getUserProjectsFolder() {
public static Path getUserProjectsFolder() {
return new File(
CBPlatform.getInstance().getWorkspace().getAbsolutePath(), USER_PROJECTS_FOLDER);
CBPlatform.getInstance().getWorkspace().getAbsolutePath(), USER_PROJECTS_FOLDER).toPath();
}
public WebSession(HttpSession httpSession) {
@@ -249,12 +250,10 @@ public class WebSession implements DBASession, DBAAuthCredentialsProvider, IAdap
DBPProject globalProject = platform.getWorkspace().getActiveProject();
String projectName;
File projectPath;
Path projectPath;
if (user != null) {
projectName = CommonUtils.escapeFileName(user.getUserId());
projectPath = new File(
getUserProjectsFolder(),
projectName);
projectPath = getUserProjectsFolder().resolve(projectName);
} else {
projectName = CommonUtils.escapeFileName(getSessionId());
// For anonymous sessions use path of global project