Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import com.google.gson.GsonBuilder;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.registry.fs.FileSystemProviderRegistry;
import org.jkiss.dbeaver.registry.fs.FSUtils;
import org.jkiss.utils.CommonUtils;

import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;

/**
Expand Down Expand Up @@ -65,30 +63,20 @@ protected synchronized Path initWorkspacePath() {
if (CommonUtils.isEmpty(workspaceLocation)) {
return defaultWorkspaceLocation;
}
URI workspaceUri = URI.create(workspaceLocation);
if (workspaceUri.getScheme() == null) {
// default filesystem
return getHomeDirectory().resolve(workspaceLocation);
} else {
var externalFsProvider =
FileSystemProviderRegistry.getInstance().getFileSystemProviderBySchema(workspaceUri.getScheme());
if (externalFsProvider == null) {
log.error("File system not found for scheme: " + workspaceUri.getScheme() + " default workspace " +
"location will be used");
try {
Path externalFsPath = FSUtils.getPathFromURI(workspaceLocation);
if (externalFsPath == null) {
log.warn("Failed to detect workspace path from URI: " + workspaceLocation +
" default workspace location will be used");
return defaultWorkspaceLocation;
}
ClassLoader fsClassloader = externalFsProvider.getInstance().getClass().getClassLoader();
try (FileSystem externalFileSystem = FileSystems.newFileSystem(workspaceUri,
System.getenv(),
fsClassloader)) {
log.info("Path from external filesystem used for workspace: " + workspaceUri);
return externalFileSystem.provider().getPath(workspaceUri);
} catch (Exception e) {
log.error("Failed to initialize workspace path: " + workspaceUri + " default workspace " +
"location will be used", e);
}
log.info("Path from external filesystem used for workspace: " + externalFsPath);
return externalFsPath;
} catch (DBException e) {
log.error("Failed to detect workspace path from URI: " + workspaceLocation +
" default workspace location will be used", e);
return defaultWorkspaceLocation;
}
return defaultWorkspaceLocation;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@

import java.nio.file.Path;

public class FSUtils {
public class WebFSUtils {
@NotNull
public static String makeUniqueFsId(@NotNull DBFVirtualFileSystem fileSystem) {
return fileSystem.getType() + "://" + fileSystem.getId();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.model.WebPropertyInfo;
import io.cloudbeaver.model.fs.FSUtils;
import io.cloudbeaver.model.fs.WebFSUtils;
import io.cloudbeaver.model.rm.DBNResourceManagerResource;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.registry.WebObjectFeatureProviderDescriptor;
Expand Down Expand Up @@ -208,7 +208,7 @@ public String getObjectId() {
if (node instanceof DBNPathBase dbnPath) {
return DBFUtils.getUriFromPath(dbnPath.getPath()).toString();
} else if (node instanceof DBNFileSystem dbnFs) {
return FSUtils.makeUniqueFsId(dbnFs.getFileSystem());
return WebFSUtils.makeUniqueFsId(dbnFs.getFileSystem());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@

import io.cloudbeaver.DBWConstants;
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.model.fs.FSUtils;
import io.cloudbeaver.model.fs.WebFSUtils;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.service.fs.DBWServiceFS;
import io.cloudbeaver.service.fs.model.FSFile;
Expand Down Expand Up @@ -69,7 +69,7 @@
}
return Arrays.stream(children)
.map(fs -> new FSFileSystem(
FSUtils.makeUniqueFsId(fs.getFileSystem()),
WebFSUtils.makeUniqueFsId(fs.getFileSystem()),
fs.getNodeUri(),
fsRegistry.getProvider(fs.getFileSystem().getProviderId()).getRequiredAuth()
)
Expand All @@ -94,7 +94,7 @@
}
var fsRegistry = FileSystemProviderRegistry.getInstance();
return new FSFileSystem(
FSUtils.makeUniqueFsId(fs.getFileSystem()),
WebFSUtils.makeUniqueFsId(fs.getFileSystem()),
fs.getNodeUri(),
fsRegistry.getProvider(fs.getFileSystem().getProviderId()).getRequiredAuth()
);
Expand All @@ -106,9 +106,9 @@
@NotNull
@Override
public FSFile getFile(@NotNull WebSession webSession, @NotNull String nodePath)
throws DBWebException {

Check warning on line 109 in server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 'throws' has incorrect indentation level 8, expected level should be 12. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java:109:9: warning: 'throws' has incorrect indentation level 8, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
try {
DBNPathBase node = FSUtils.getNodeByPath(webSession, nodePath);
DBNPathBase node = WebFSUtils.getNodeByPath(webSession, nodePath);
return new FSFile(node);
} catch (Exception e) {
throw new DBWebException("Failed to found file: " + e.getMessage(), e);
Expand All @@ -118,9 +118,9 @@
@NotNull
@Override
public FSFile[] getFiles(@NotNull WebSession webSession, @NotNull String parentPath)
throws DBWebException {

Check warning on line 121 in server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 'throws' has incorrect indentation level 8, expected level should be 12. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java:121:9: warning: 'throws' has incorrect indentation level 8, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
try {
DBNPathBase folderPath = FSUtils.getNodeByPath(webSession, parentPath);
DBNPathBase folderPath = WebFSUtils.getNodeByPath(webSession, parentPath);
var children = folderPath.getChildren(webSession.getProgressMonitor());
if (children == null) {
return new FSFile[0];
Expand All @@ -138,9 +138,9 @@
@NotNull
@Override
public String readFileContent(@NotNull WebSession webSession, @NotNull String nodePath)
throws DBWebException {

Check warning on line 141 in server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 'throws' has incorrect indentation level 8, expected level should be 12. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java:141:9: warning: 'throws' has incorrect indentation level 8, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
try {
Path filePath = FSUtils.getPathFromNode(webSession, nodePath);
Path filePath = WebFSUtils.getPathFromNode(webSession, nodePath);
var data = Files.readAllBytes(filePath);
return new String(data, StandardCharsets.UTF_8);
} catch (Exception e) {
Expand All @@ -155,10 +155,10 @@
@NotNull String data,
boolean forceOverwrite
)
throws DBWebException {

Check warning on line 158 in server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 'throws' has incorrect indentation level 8, expected level should be 12. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java:158:9: warning: 'throws' has incorrect indentation level 8, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
validateEditPermissions(webSession);
try {
DBNPathBase node = FSUtils.getNodeByPath(webSession, nodePath);
DBNPathBase node = WebFSUtils.getNodeByPath(webSession, nodePath);
Path filePath = node.getPath();
if (!forceOverwrite) {
throw new DBException("Cannot overwrite exist file");
Expand All @@ -179,7 +179,7 @@
) throws DBWebException {
validateEditPermissions(webSession);
try {
DBNPathBase parentNode = FSUtils.getNodeByPath(webSession, parentPath);
DBNPathBase parentNode = WebFSUtils.getNodeByPath(webSession, parentPath);
if (!Files.isDirectory(parentNode.getPath())) {
throw new DBException(MessageFormat.format("Node ''{0}'' is not a directory", parentPath));
}
Expand All @@ -200,10 +200,10 @@
) throws DBWebException {
validateEditPermissions(webSession);
try {
DBNPathBase oldNode = FSUtils.getNodeByPath(webSession, oldNodePath);
DBNPathBase oldNode = WebFSUtils.getNodeByPath(webSession, oldNodePath);
DBNPathBase oldParentNode = (DBNPathBase) oldNode.getParentNode();
String fileName = oldNode.getName();
DBNPathBase parentNode = FSUtils.getNodeByPath(webSession, parentNodePath);
DBNPathBase parentNode = WebFSUtils.getNodeByPath(webSession, parentNodePath);
Path parentPath = parentNode.getPath();
if (!Files.isDirectory(parentPath)) {
throw new DBException(MessageFormat.format("Node ''{0}'' is not a directory", parentPath));
Expand All @@ -227,7 +227,7 @@
validateEditPermissions(webSession);
validateFilename(newName);
try {
DBNPathBase node = FSUtils.getNodeByPath(webSession, nodePath);
DBNPathBase node = WebFSUtils.getNodeByPath(webSession, nodePath);
node.rename(webSession.getProgressMonitor(), newName);
return new FSFile(node);
} catch (Exception e) {
Expand All @@ -243,9 +243,9 @@
) throws DBWebException {
validateEditPermissions(webSession);
try {
DBNPathBase oldNode = FSUtils.getNodeByPath(webSession, oldNodePath);
DBNPathBase oldNode = WebFSUtils.getNodeByPath(webSession, oldNodePath);
String fileName = oldNode.getName();
DBNPathBase parentNode = FSUtils.getNodeByPath(webSession, parentNodePath);
DBNPathBase parentNode = WebFSUtils.getNodeByPath(webSession, parentNodePath);
Path parentPath = parentNode.getPath();
if (!Files.isDirectory(parentPath)) {
throw new DBException(MessageFormat.format("Node ''{0}'' is not a directory", parentPath));
Expand All @@ -267,7 +267,7 @@
) throws DBWebException {
validateEditPermissions(webSession);
try {
DBNPathBase parentNode = FSUtils.getNodeByPath(webSession, parentPath);
DBNPathBase parentNode = WebFSUtils.getNodeByPath(webSession, parentPath);
if (!Files.isDirectory(parentNode.getPath())) {
throw new DBException(MessageFormat.format("Node ''{0}'' is not a directory", parentPath));
}
Expand All @@ -287,7 +287,7 @@
) throws DBWebException {
validateEditPermissions(webSession);
try {
DBNPathBase node = FSUtils.getNodeByPath(webSession, nodePath);
DBNPathBase node = WebFSUtils.getNodeByPath(webSession, nodePath);
Path path = node.getPath();
Files.delete(path);
DBNPathBase parentNode = (DBNPathBase) node.getParentNode();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@

import io.cloudbeaver.DBWConstants;
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.model.fs.FSUtils;
import io.cloudbeaver.model.fs.WebFSUtils;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.service.WebServiceServletBase;
Expand Down Expand Up @@ -74,7 +74,7 @@ protected void processServiceRequest(WebSession session, HttpServletRequest requ
}

private void doGet(WebSession session, HttpServletRequest request, HttpServletResponse response) throws DBException, IOException {
Path path = FSUtils.getPathFromNode(session, request.getParameter("nodePath"));
Path path = WebFSUtils.getPathFromNode(session, request.getParameter("nodePath"));
session.addInfoMessage("Download data ...");
response.setHeader("Content-Type", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + path.getFileName() + "\"");
Expand All @@ -93,7 +93,7 @@ private void doPost(WebSession session, HttpServletRequest request, HttpServletR
if (CommonUtils.isEmpty(parentNodePath)) {
throw new DBException("Parent node path parameter is not found");
}
DBNPathBase node = FSUtils.getNodeByPath(session, parentNodePath);
DBNPathBase node = WebFSUtils.getNodeByPath(session, parentNodePath);
Path path = node.getPath();
try {
for (Part part : request.getParts()) {
Expand Down
Loading