mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Cb 3959 UI file system navigator view (#2069)
* CB-4061 file systems feature * CB-4061 return rm fs navigator nodes * CB-3959 fix tests * CB-3959 encode spaces in rm uri
This commit is contained in:
@@ -8,5 +8,7 @@
|
||||
class="io.cloudbeaver.service.fs.WebServiceBindingFS">
|
||||
</service>
|
||||
</extension>
|
||||
|
||||
<extension point="io.cloudbeaver.feature">
|
||||
<feature id="fileSystems" label="File Systems" description="File Systems"/>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
||||
+3
@@ -29,6 +29,8 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
@@ -80,6 +82,7 @@ public class RMNIOFileSystemProvider extends NIOFileSystemProvider {
|
||||
}
|
||||
RMNIOFileSystem rmNioFileSystem = new RMNIOFileSystem(projectId, this);
|
||||
String resourcePath = uri.getPath();
|
||||
resourcePath = URLDecoder.decode(resourcePath, StandardCharsets.UTF_8);
|
||||
if (CommonUtils.isNotEmpty(resourcePath) && projectId == null) {
|
||||
throw new IllegalArgumentException("Project is not specified in URI");
|
||||
}
|
||||
|
||||
+25
-11
@@ -25,9 +25,14 @@ import org.jkiss.utils.CommonUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RMPath extends NIOPath {
|
||||
@NotNull
|
||||
@@ -71,7 +76,7 @@ public class RMPath extends NIOPath {
|
||||
if (ArrayUtils.isEmpty(parts)) {
|
||||
return this;
|
||||
}
|
||||
return new RMPath(rmNioFileSystem, parts[parts.length - 1]);
|
||||
return new RMPath(new RMNIOFileSystem(null, getFileSystem().rmProvider()), parts[parts.length - 1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,22 +127,31 @@ public class RMPath extends NIOPath {
|
||||
@Override
|
||||
public URI toUri() {
|
||||
var fileSystem = getFileSystem();
|
||||
var uriBuilder = new StringBuilder(fileSystem.provider().getScheme())
|
||||
.append("://");
|
||||
|
||||
if (rmProjectId != null) {
|
||||
uriBuilder.append(rmProjectId);
|
||||
var uriBuilder = new StringBuilder();
|
||||
if (isAbsolute()) {
|
||||
uriBuilder.append(fileSystem.provider().getScheme())
|
||||
.append("://");
|
||||
}
|
||||
|
||||
String rmResourcePath = getResourcePath();
|
||||
if (rmResourcePath != null) {
|
||||
uriBuilder.append(fileSystem.getSeparator())
|
||||
.append(rmResourcePath);
|
||||
}
|
||||
var paths = new ArrayList<String>();
|
||||
paths.add(rmProjectId);
|
||||
paths.add(getResourcePath());
|
||||
|
||||
uriBuilder.append(
|
||||
paths.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(s -> URLEncoder.encode(s, StandardCharsets.UTF_8))
|
||||
.collect(Collectors.joining(fileSystem.getSeparator()))
|
||||
);
|
||||
|
||||
return URI.create(uriBuilder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbsolute() {
|
||||
return rmNioFileSystem.getRmProjectId() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path toAbsolutePath() {
|
||||
if (isAbsolute()) {
|
||||
|
||||
Reference in New Issue
Block a user