Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cb 3959 UI file system navigator view #2069

Merged
merged 5 commits into from
Oct 20, 2023
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
4 changes: 3 additions & 1 deletion server/bundles/io.cloudbeaver.service.fs/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
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;
Expand Down Expand Up @@ -80,6 +82,7 @@ public Path getPath(URI uri) {
}
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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@

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
Expand Down Expand Up @@ -71,7 +76,7 @@ public Path getFileName() {
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
Expand Down Expand Up @@ -122,22 +127,31 @@ public Path resolve(String other) {
@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()) {
Expand Down
Loading