Skip to content
Open
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: 4 additions & 0 deletions hub/src/main/java/cloud/katta/protocols/hub/HubSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ch.cyberduck.core.features.Move;
import ch.cyberduck.core.features.Read;
import ch.cyberduck.core.features.Scheduler;
import ch.cyberduck.core.features.Share;
import ch.cyberduck.core.features.Timestamp;
import ch.cyberduck.core.features.Touch;
import ch.cyberduck.core.features.Write;
Expand Down Expand Up @@ -235,6 +236,9 @@ public <T> T _getFeature(final Class<T> type) {
if(type == Scheduler.class) {
return (T) access;
}
if(type == Share.class) {
return (T) new HubVaultShareFeature(this);
}
if(type == Home.class) {
return (T) (Home) Home::root;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ protected S3CredentialsStrategy configureCredentialsStrategy(final HttpClientBui
log.debug("Configured {} for vault {}", storage, vaultId);
final Path bucket = new Path(vaultStorageMetadata.getDefaultPath() /*Bucket Name*/, EnumSet.of(Path.Type.directory, Path.Type.volume),
new DefaultPathAttributes()
.setFileId(vaultId.toString())
.setRegion(HubStorageLocationService.StorageLocation.fromMetadata(vaultStorageMetadata).getIdentifier())
.setDisplayname(vaultStorageMetadata.getNickname())
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2026 shift7 GmbH. All rights reserved.
*/

package cloud.katta.protocols.hub;

import ch.cyberduck.core.DescriptiveUrl;
import ch.cyberduck.core.PasswordCallback;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.features.Share;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;

import cloud.katta.client.ApiException;
import cloud.katta.client.api.AuthorityResourceApi;
import cloud.katta.client.api.VaultResourceApi;
import cloud.katta.client.model.AuthorityDto;
import cloud.katta.client.model.Role;
import cloud.katta.client.model.UserDto;
import cloud.katta.protocols.hub.exceptions.HubExceptionMappingService;

public class HubVaultShareFeature implements Share<Void, Void> {

private final HubSession session;

public HubVaultShareFeature(final HubSession session) {
this.session = session;
}

@Override
public boolean isSupported(final Path file, final Type type) {
switch(type) {
case download:
// Only when owner
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TODO or how do we ensure ownership?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenkins What API can be used to determine the user role?

if(file.isDirectory()) {
return file.getParent().isRoot();
}
}
return false;
}

@Override
public Set<Sharee> getSharees(final Type type) throws BackgroundException {
try {
switch(type) {
case download:
final Set<Sharee> users = new LinkedHashSet<>();
for(AuthorityDto authority : new AuthorityResourceApi(session.getClient()).apiAuthoritiesSearchGet("%", false)) {
final Object instance = authority.getActualInstanceRecursively();
if(instance instanceof UserDto) {
final UserDto user = (UserDto) instance;
users.add(new Sharee(user.getId(), String.format("%s (%s)", user.getName(), user.getEmail())));
}
}
return users;
}
return Collections.emptySet();
}
catch(ApiException e) {
throw new HubExceptionMappingService().map(e);
}
}

@Override
public DescriptiveUrl toDownloadUrl(final Path file, final Sharee sharee, final Void options, final PasswordCallback callback) throws BackgroundException {
try {
new VaultResourceApi(session.getClient()).apiVaultsVaultIdUsersUserIdPut(sharee.getIdentifier(),
UUID.fromString(file.attributes().getFileId()), Role.MEMBER);
return DescriptiveUrl.EMPTY;
}
catch(ApiException e) {
throw new HubExceptionMappingService().map(e);
}
}

@Override
public DescriptiveUrl toUploadUrl(final Path file, final Sharee sharee, final Void options, final PasswordCallback callback) throws BackgroundException {
return DescriptiveUrl.EMPTY;
}
}
Loading