Compare commits

..

6 Commits

Author SHA1 Message Date
Lucio Lelii 3ad396ea2f removed 2024-11-29 11:10:08 +01:00
Lucio Lelii 9f8f9e375c updated 2024-11-29 10:59:46 +01:00
Lucio Lelii ad6022647e commit for release 2024-11-27 14:53:51 +01:00
Lucio Lelii 38ab992b28 jnr-fuse upgraded 2024-11-27 14:50:32 +01:00
Lucio Lelii bd31d63bd5 update 2024-11-27 14:49:01 +01:00
Lucio Lelii ca6476fffa shub client 2.0.0 integrated 2024-11-27 14:46:07 +01:00
9 changed files with 212 additions and 193 deletions

View File

@ -9,7 +9,6 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
@ -23,10 +22,9 @@
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>

View File

@ -1,8 +1,8 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -2,17 +2,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.data-access.sh-fuse-integration # Changelog for org.gcube.data-access.sh-fuse-integration
## [v3.0.0] ## [v2.1.0-SNAPSHOT]
- porting to gcube-bom 4.0.0 - porting to storagehub-client-2.0.0
## [v2.0.1] 2021-02-09
- all logs set to WARN [#22814]
## [v2.0.0] 2021-05-19 ## [v2.0.0] 2021-05-19
- porting to uma token [#21441] - porting to uma token [#21441]
## [v1.1.1] 2021-01-15 ## [v1.1.1] 2021-01-15

245
pom.xml
View File

@ -1,116 +1,133 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.data-access</groupId> <groupId>org.gcube.data-access</groupId>
<artifactId>sh-fuse-integration</artifactId> <artifactId>sh-fuse-integration</artifactId>
<version>3.0.0</version> <version>2.1.0-SNAPSHOT</version>
<name>SHFuseIntegration</name> <name>SHFuseIntegration</name>
<parent>
<artifactId>maven-parent</artifactId> <parent>
<groupId>org.gcube.tools</groupId> <artifactId>maven-parent</artifactId>
<version>1.2.0</version> <groupId>org.gcube.tools</groupId>
<relativePath /> <version>1.2.0</version>
</parent> <relativePath/>
<scm> </parent>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git</developerConnection> <scm>
<url>https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration</url> <connection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git</connection>
</scm> <developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git
<repositories> </developerConnection>
<repository> <url>https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration</url>
<id>central</id> </scm>
<name>bintray</name>
<url>https://jcenter.bintray.com</url> <properties>
</repository> <maven.compiler.source>1.8</maven.compiler.source>
</repositories> <maven.compiler.target>1.8</maven.compiler.target>
<properties> </properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <repositories>
</properties> <repository>
<dependencyManagement> <id>central</id>
<dependencies> <name>bintray</name>
<dependency> <url>https://jcenter.bintray.com</url>
<groupId>org.gcube.distribution</groupId> </repository>
<artifactId>gcube-bom</artifactId> </repositories>
<version>4.0.0</version>
<type>pom</type> <dependencyManagement>
<scope>import</scope> <dependencies>
</dependency> <dependency>
</dependencies> <groupId>org.gcube.distribution</groupId>
</dependencyManagement> <artifactId>gcube-bom</artifactId>
<dependencies> <version>2.4.1-SNAPSHOT</version>
<dependency> <type>pom</type>
<groupId>com.github.serceman</groupId> <scope>import</scope>
<artifactId>jnr-fuse</artifactId> </dependency>
<version>0.5.8</version> </dependencies>
</dependency> </dependencyManagement>
<dependency>
<groupId>org.gcube.common</groupId> <dependencies>
<artifactId>gxJRS</artifactId> <dependency>
</dependency> <groupId>com.github.serceman</groupId>
<dependency> <artifactId>jnr-fuse</artifactId>
<groupId>org.gcube.common</groupId> <version>0.5.8</version>
<artifactId>common-security</artifactId> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.gcube.common</groupId>
<groupId>org.gcube.common.security</groupId> <artifactId>gxJRS</artifactId>
<artifactId>gcube-secrets</artifactId> </dependency>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId> <artifactId>common-authorization</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.common</groupId> <dependency>
<artifactId>storagehub-model</artifactId> <groupId>org.gcube.common</groupId>
</dependency> <artifactId>storagehub-client-library</artifactId>
<dependency> </dependency>
<groupId>org.gcube.core</groupId> <dependency>
<artifactId>common-gcube-calls</artifactId> <groupId>org.gcube.common</groupId>
</dependency> <artifactId>storagehub-model</artifactId>
<dependency> </dependency>
<groupId>org.cache2k</groupId> <dependency>
<artifactId>cache2k-jcache</artifactId> <groupId>org.gcube.core</groupId>
<version>1.2.0.Final</version> <artifactId>common-gcube-calls</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.cache2k</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>cache2k-jcache</artifactId>
</dependency> <version>1.2.0.Final</version>
<dependency> </dependency>
<groupId>junit</groupId> <dependency>
<artifactId>junit</artifactId> <groupId>org.slf4j</groupId>
<version>4.11</version> <artifactId>slf4j-api</artifactId>
<scope>test</scope> </dependency>
</dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>junit</groupId>
<artifactId>logback-classic</artifactId> <artifactId>junit</artifactId>
</dependency> <version>4.11</version>
</dependencies> <scope>test</scope>
<build> </dependency>
<plugins> <dependency>
<plugin> <groupId>ch.qos.logback</groupId>
<groupId>org.apache.maven.plugins</groupId> <artifactId>logback-classic</artifactId>
<artifactId>maven-shade-plugin</artifactId> </dependency>
<version>3.4.1</version> </dependencies>
<executions>
<execution> <build>
<phase>package</phase> <plugins>
<goals> <plugin>
<goal>shade</goal> <groupId>org.apache.maven.plugins</groupId>
</goals> <artifactId>maven-assembly-plugin</artifactId>
<configuration> <executions>
<transformers> <execution>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <phase>package</phase>
<mainClass>org.gcube.data.access.storagehub.fs.StorageHubFuseLauncher</mainClass> <goals>
</transformer> <goal>single</goal>
</transformers> </goals>
</configuration> <configuration>
</execution> <archive>
</executions> <manifest>
</plugin> <mainClass>org.gcube.data.access.storagehub.fs.StorageHubFuseLauncher
</plugins> </mainClass>
</build> </manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.8</target>
<source>1.8</source>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -33,7 +33,9 @@ public class PathUtils {
while (path.substring(path.length() - 1).equals("/")) { while (path.substring(path.length() - 1).equals("/")) {
path = path.substring(0, path.length() - 1); path = path.substring(0, path.length() - 1);
} }
if (path.isEmpty()) {
return "";
}
return path.substring(path.lastIndexOf("/") + 1); return path.substring(path.lastIndexOf("/") + 1);
} }

View File

@ -9,10 +9,10 @@ import java.util.concurrent.TimeUnit;
import org.cache2k.Cache; import org.cache2k.Cache;
import org.cache2k.Cache2kBuilder; import org.cache2k.Cache2kBuilder;
import org.gcube.common.security.AuthorizedTasks; import org.gcube.common.authorization.library.AuthorizedTasks;
import org.gcube.common.security.providers.SecretManagerProvider; import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.security.secrets.Secret; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.security.secrets.UmaTokenSecret; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.dsl.ContainerType; import org.gcube.common.storagehub.client.dsl.ContainerType;
import org.gcube.common.storagehub.client.dsl.FileContainer; import org.gcube.common.storagehub.client.dsl.FileContainer;
import org.gcube.common.storagehub.client.dsl.FolderContainer; import org.gcube.common.storagehub.client.dsl.FolderContainer;
@ -44,7 +44,9 @@ public class StorageHubFS extends FuseStubFS {
StorageHubClient client; StorageHubClient client;
Secret secret; String token;
String scope;
HashMap<String, SHFile> tempFiles = new HashMap<>(); HashMap<String, SHFile> tempFiles = new HashMap<>();
@ -57,15 +59,16 @@ public class StorageHubFS extends FuseStubFS {
private FolderContainer rootDirectory; private FolderContainer rootDirectory;
public StorageHubFS(String token) { public StorageHubFS(String token, String scope) {
super(); super();
this.secret = new UmaTokenSecret(token); this.token = token;
this.scope = scope;
logger.debug("using token {}", token); logger.debug("using token {} in scope {}", token , scope);
SecretManagerProvider.set(secret);
ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
client = new StorageHubClient(); client = new StorageHubClient();
rootDirectory = client.getWSRoot(); rootDirectory = client.getWSRoot();
cache = new Cache2kBuilder<String, ItemContainer<Item>>() {} cache = new Cache2kBuilder<String, ItemContainer<Item>>() {}
@ -81,7 +84,8 @@ public class StorageHubFS extends FuseStubFS {
*/ */
@Override @Override
public synchronized int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) { public synchronized int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) {
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
logger.trace("{}) calling write {} - {} ",Thread.currentThread().getName(), size , offset); logger.trace("{}) calling write {} - {} ",Thread.currentThread().getName(), size , offset);
SHFile file = tempFiles.get(path); SHFile file = tempFiles.get(path);
@ -109,7 +113,8 @@ public class StorageHubFS extends FuseStubFS {
*/ */
@Override @Override
public synchronized int create(final String path, @mode_t long mode, FuseFileInfo fi) { public synchronized int create(final String path, @mode_t long mode, FuseFileInfo fi) {
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling create "+path); logger.trace(Thread.currentThread().getName()+" ) calling create "+path);
if (pathUtils.getPath(path) != null) { if (pathUtils.getPath(path) != null) {
@ -161,7 +166,8 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int getattr(String path, FileStat stat) { public int getattr(String path, FileStat stat) {
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling getattr "+path); logger.trace(Thread.currentThread().getName()+" ) calling getattr "+path);
if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) { if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) {
@ -223,7 +229,8 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int mkdir(String path, @mode_t long mode) { public int mkdir(String path, @mode_t long mode) {
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling mkdir"); logger.trace(Thread.currentThread().getName()+" ) calling mkdir");
@ -252,7 +259,8 @@ public class StorageHubFS extends FuseStubFS {
*/ */
@Override @Override
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address()); logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address());
@ -319,7 +327,8 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) { public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) {
logger.trace("readdir called"); logger.trace("readdir called");
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling readdir "+path); logger.trace(Thread.currentThread().getName()+" ) calling readdir "+path);
if (path.contains(".Trash")) return 0; if (path.contains(".Trash")) return 0;
@ -411,7 +420,8 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int rename(String path, String newName) { public int rename(String path, String newName) {
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
ItemContainer<? extends Item> folder = pathUtils.getPath(path); ItemContainer<? extends Item> folder = pathUtils.getPath(path);
if (folder == null) { if (folder == null) {
@ -448,7 +458,8 @@ public class StorageHubFS extends FuseStubFS {
if (path.equals("/"+VREFOLDERS_NAME)) if (path.equals("/"+VREFOLDERS_NAME))
return -ErrorCodes.EACCES(); return -ErrorCodes.EACCES();
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
ItemContainer<? extends Item> folder = pathUtils.getPath(path); ItemContainer<? extends Item> folder = pathUtils.getPath(path);
if (folder == null) { if (folder == null) {
@ -457,9 +468,8 @@ public class StorageHubFS extends FuseStubFS {
if (folder.getType()!=ContainerType.FOLDER) { if (folder.getType()!=ContainerType.FOLDER) {
return -ErrorCodes.ENOTDIR(); return -ErrorCodes.ENOTDIR();
} }
ScopeProvider.instance.set(scope);
SecretManagerProvider.set(secret); AccessTokenProvider.instance.set(token);
try { try {
checkSpecialFolderRemove(path); checkSpecialFolderRemove(path);
@ -487,9 +497,8 @@ public class StorageHubFS extends FuseStubFS {
*/ */
@Override @Override
public int unlink(String path) { public int unlink(String path) {
ScopeProvider.instance.set(scope);
SecretManagerProvider.set(secret); AccessTokenProvider.instance.set(token);
ItemContainer<? extends Item> file = pathUtils.getPath(path); ItemContainer<? extends Item> file = pathUtils.getPath(path);
if (file == null) { if (file == null) {
@ -498,9 +507,8 @@ public class StorageHubFS extends FuseStubFS {
if (file.getType()!=ContainerType.FILE) { if (file.getType()!=ContainerType.FILE) {
return -ErrorCodes.EISDIR(); return -ErrorCodes.EISDIR();
} }
ScopeProvider.instance.set(scope);
SecretManagerProvider.set(secret); AccessTokenProvider.instance.set(token);
try { try {
file.delete(); file.delete();
cache.remove(path); cache.remove(path);
@ -535,8 +543,8 @@ public class StorageHubFS extends FuseStubFS {
public int truncate(String path, long size) { public int truncate(String path, long size) {
logger.info("truncate called {} ",path); logger.info("truncate called {} ",path);
SecretManagerProvider.set(secret); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token);
cache.remove(path); cache.remove(path);
uploadFile(path); uploadFile(path);
return 0; return 0;

View File

@ -7,9 +7,10 @@ public class StorageHubFuseLauncher {
public static void main(String ...args) { public static void main(String ...args) {
String token = args[0]; String token = args[0];
String path = args[1]; String scope = args[1];
String path = args[2];
StorageHubFS shFS= new StorageHubFS(token); StorageHubFS shFS= new StorageHubFS(token, scope);
shFS.mount(Paths.get(path), true, true); shFS.mount(Paths.get(path), true, true);
} }

View File

@ -1,20 +1,17 @@
<configuration> <configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<file>./fuse.log</file> <encoder>
<append>true</append> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n</pattern>
<encoder> </encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger: %msg%n </appender>
</pattern>
</encoder>
</appender>
<logger name="org.gcube.data.access.storagehub.fs" level="INFO" /> <logger name="org.gcube.data.access.storagehub.fs" level="TRACE" />
<logger name="org.gcube" level="INFO" /> <logger name="org.gcube" level="WARN" />
<root level="WARN"> <root level="WARN">
<appender-ref ref="FILE" /> <appender-ref ref="STDOUT" />
</root> </root>
</configuration> </configuration>

View File

@ -1,6 +1,7 @@
package org.gcube.data.access.storagehub.fuse; package org.gcube.data.access.storagehub.fuse;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Objects;
import org.gcube.data.access.storagehub.fs.StorageHubFS; import org.gcube.data.access.storagehub.fs.StorageHubFS;
import org.junit.Test; import org.junit.Test;
@ -9,19 +10,17 @@ import jnr.ffi.Platform;
public class FuseTest { public class FuseTest {
@Test
public void mount() { public void mount() {
StorageHubFS memfs = new StorageHubFS(""); StorageHubFS memfs = new StorageHubFS("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0","/gcube");
try { try {
String path; String path;
switch (Platform.getNativePlatform().getOS()) { if (Objects.requireNonNull(Platform.getNativePlatform().getOS()) == Platform.OS.WINDOWS) {
case WINDOWS: System.out.println("Im here");
System.out.println("Im here"); path = "J:\\";
path = "J:\\"; } else
break; path = "/home/lucio/java/mnt";
default:
path = "/Users/lucio/java/mnt";
}
memfs.mount(Paths.get(path), true, true); memfs.mount(Paths.get(path), true, true);
} finally { } finally {
memfs.umount(); memfs.umount();