mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
dbeaver/dbeaver-ee#876 Migrate to NIO
This commit is contained in:
+7
-6
@@ -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());
|
||||
|
||||
+5
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user