diff --git a/.classpath b/.classpath index a68c7d6..3c7c36f 100644 --- a/.classpath +++ b/.classpath @@ -9,6 +9,7 @@ + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 8926067..c858648 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,7 +1,11 @@ + + + - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index f6b5f68..3a873ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v2.0.0-SNAPSHOT] - [2022-02-07] +## [v3.0.0-SNAPSHOT] - [2023-05-23] + +### Feature + +porting GCUBE-BOM 3.0 + +## [v2.0.0] - [2022-02-07] ### Feature diff --git a/pom.xml b/pom.xml index 20081b7..40bc9d9 100644 --- a/pom.xml +++ b/pom.xml @@ -2,65 +2,41 @@ 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"> 4.0.0 - maven-parent org.gcube.tools 1.1.0 - scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub-client-library.git scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub-client-library.git https://code-repo.d4science.org/gCubeSystem/storagehub-client-library - org.gcube.common storagehub-client-library - 2.0.0-SNAPSHOT + 3.0.0-SNAPSHOT storagehub-client-library - 1.8 1.8 - - org.gcube.distribution gcube-bom - 2.1.0-SNAPSHOT + 3.0.0-SNAPSHOT pom import - - - - - - - junit - junit - 4.11 - test - - - gov.nih.imagej - imagej - 1.47 - test - org.gcube.common storagehub-model - org.glassfish.jersey.media jersey-media-json-jackson @@ -69,7 +45,6 @@ org.glassfish.jersey.media jersey-media-multipart - org.gcube.core common-gcube-calls @@ -77,21 +52,37 @@ org.gcube.common common-jaxrs-client - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) - org.gcube.core common-generic-clients - org.slf4j slf4j-api - - - + + com.sun.xml.ws + rt + 2.3.3 + + + com.sun.xml.bind + jaxb-core + + + com.sun.xml.bind + jaxb-impl + runtime + + + org.gcube.common + common-security + + + org.gcube.common.security + gcube-secrets + junit junit @@ -115,6 +106,11 @@ 5.3 test + + gov.nih.imagej + imagej + 1.47 + test + - \ No newline at end of file diff --git a/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultGroupManager.java b/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultGroupManager.java index e5a5b44..fa176f3 100644 --- a/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultGroupManager.java +++ b/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultGroupManager.java @@ -43,7 +43,7 @@ public class DefaultGroupManager extends DefaultManagerClient implements GroupMa else if (response.getHTTPCode()==403) throw new UserNotAuthorizedException("the call to this method is not allowed for the user"); else - throw new BackendGenericError(); + throw new BackendGenericError("response is "+response.getHTTPCode()); } diff --git a/src/test/java/org/gcube/data/access/fs/ImportTest.java b/src/test/java/org/gcube/data/access/fs/ImportTest.java index 1619841..2e450ee 100644 --- a/src/test/java/org/gcube/data/access/fs/ImportTest.java +++ b/src/test/java/org/gcube/data/access/fs/ImportTest.java @@ -1,14 +1,9 @@ package org.gcube.data.access.fs; -import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; import java.net.URL; import java.util.List; -import java.util.Properties; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.storagehub.client.dsl.ContainerType; import org.gcube.common.storagehub.client.dsl.FileContainer; import org.gcube.common.storagehub.client.dsl.FolderContainer; @@ -20,29 +15,7 @@ import org.junit.Test; public class ImportTest { - private static final String propFile = "/home/lucio/tokens.properties"; - - private static final String devEnv = "dev-devvre"; - private static final String prodEnv = "prod-root"; - - - public void setUp(String env){ - - try(InputStream is = new FileInputStream(new File(propFile))){ - Properties prop = new Properties(); - prop.load(is); - String value =(String)prop.get(env); - String[] splitValue = value.split(","); - String token = splitValue[1]; - //SecretManagerProvider.instance.set(new GCubeSecret(token)); - - SecurityTokenProvider.instance.set(token); - ScopeProvider.instance.set(splitValue[0]); - } catch (Exception e) { - e.printStackTrace(); - } - - } + @Test @@ -58,7 +31,7 @@ public class ImportTest { } public void importTest(String folderId, String relativePath) throws Exception { - setUp(prodEnv); + Initializer.setUp(); StorageHubClient shc = new StorageHubClient(); FolderContainer fc = shc.open(folderId).asFolder(); @@ -68,10 +41,10 @@ public class ImportTest { for (ItemContainer itemContainer : items) { if (itemContainer.getType() == ContainerType.FOLDER) { new Thread(()-> createInDev(itemContainer.get(), itemContainer.getType(), relativePath, null)).run(); - setUp(prodEnv); + Initializer.setUp(); importTest(itemContainer.getId(), relativePath == null ? itemContainer.get().getName() : relativePath+"/"+itemContainer.get().getName() ); } else if (itemContainer.getType() == ContainerType.FILE){ - setUp(prodEnv); + Initializer.setUp(); final URL publicLink = ((FileContainer)itemContainer).getPublicLink(); System.out.println("publik Link "+publicLink.toString()); new Thread(()-> createInDev(itemContainer.get(), itemContainer.getType(), relativePath, publicLink)).run(); @@ -83,7 +56,7 @@ public class ImportTest { public void createInDev(T item, ContainerType type, String relativePath, URL publicLink){ - setUp(devEnv); + Initializer.setUp(); StorageHubClient shc = new StorageHubClient(); try { FolderContainer currentFolder = shc.openVREFolder().openByRelativePath("testLucio").asFolder(); diff --git a/src/test/java/org/gcube/data/access/fs/Initializer.java b/src/test/java/org/gcube/data/access/fs/Initializer.java new file mode 100644 index 0000000..409244c --- /dev/null +++ b/src/test/java/org/gcube/data/access/fs/Initializer.java @@ -0,0 +1,38 @@ +package org.gcube.data.access.fs; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Properties; + +import org.gcube.common.security.providers.SecretManagerProvider; +import org.gcube.common.security.secrets.GCubeSecret; + +public class Initializer { + + private static final String propFile = "/Users/lucio/Documents/tokens.properties"; + + private static final String devEnv = "dev-devvre"; + + + public static void setUp(String env){ + + try(InputStream is = new FileInputStream(new File(propFile))){ + Properties prop = new Properties(); + prop.load(is); + String value =(String)prop.get(env); + String[] splitValue = value.split(","); + String token = splitValue[1]; + SecretManagerProvider.instance.set(new GCubeSecret(token)); + + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public static void setUp(){ + setUp(devEnv); + } +} diff --git a/src/test/java/org/gcube/data/access/fs/Items.java b/src/test/java/org/gcube/data/access/fs/Items.java index 3b3322b..cc84313 100644 --- a/src/test/java/org/gcube/data/access/fs/Items.java +++ b/src/test/java/org/gcube/data/access/fs/Items.java @@ -14,11 +14,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Properties; -import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.storagehub.client.StreamDescriptor; import org.gcube.common.storagehub.client.dsl.ContainerType; import org.gcube.common.storagehub.client.dsl.FileContainer; @@ -32,7 +29,6 @@ import org.gcube.common.storagehub.client.proxies.UserManagerClient; import org.gcube.common.storagehub.model.Metadata; import org.gcube.common.storagehub.model.acls.AccessType; import org.gcube.common.storagehub.model.exceptions.StorageHubException; -import org.gcube.common.storagehub.model.items.AbstractFileItem; import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.Item; import org.junit.BeforeClass; @@ -42,36 +38,15 @@ import org.junit.Test; public class Items { - private static final String propFile = "/home/lucio/tokens.properties"; - - private static final String tokens = "dev-root"; - //private static final String tokens = "prod-root"; - @BeforeClass public static void setUp(){ - - try(InputStream is = new FileInputStream(new File(propFile))){ - Properties prop = new Properties(); - prop.load(is); - String value =(String)prop.get(tokens); - String[] splitValue = value.split(","); - String token = splitValue[1]; - //SecretManagerProvider.instance.set(new GCubeSecret(token)); - - SecurityTokenProvider.instance.set(token); - ScopeProvider.instance.set(splitValue[0]); - } catch (Exception e) { - e.printStackTrace(); - } - + Initializer.setUp(); } - - + @Test public void addUserToVRe() throws StorageHubException { StorageHubClient shc = new StorageHubClient(); - - + String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt"; try(InputStream is = new FileInputStream(new File(vresFile))){ @@ -97,6 +72,13 @@ public class Items { } + @Test + public void opeVREfolder() throws StorageHubException{ + StorageHubClient shc = new StorageHubClient(); + shc.openVREFolder(); + + } + @Test public void removeVersion() throws Exception { diff --git a/src/test/java/org/gcube/data/access/fs/TestCall.java b/src/test/java/org/gcube/data/access/fs/TestCall.java index 5bf97ae..470eb33 100644 --- a/src/test/java/org/gcube/data/access/fs/TestCall.java +++ b/src/test/java/org/gcube/data/access/fs/TestCall.java @@ -4,18 +4,14 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.InputStream; import java.nio.file.Files; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.scope.api.ScopeProvider; //code-repo.d4science.org/gCubeSystem/storagehub-client-library.git import org.gcube.common.storagehub.client.StreamDescriptor; import org.gcube.common.storagehub.client.plugins.AbstractPlugin; @@ -46,29 +42,9 @@ public class TestCall { private static Logger log = LoggerFactory.getLogger(TestCall.class); - private static final String propFile = "/home/lucio/tokens.properties"; - - private static final String tokens = "dev-root"; - @BeforeClass public static void setUp(){ - - try(InputStream is = new FileInputStream(new File(propFile))){ - Properties prop = new Properties(); - prop.load(is); - String value =(String)prop.get(tokens); - String[] splitValue = value.split(","); - String token = splitValue[1]; - String scope = splitValue[0]; - //SecretManagerProvider.instance.set(new GCubeSecret(token)); - - SecurityTokenProvider.instance.set(token); - ScopeProvider.instance.set(scope); - - } catch (Exception e) { - e.printStackTrace(); - } - + Initializer.setUp(); } diff --git a/src/test/java/org/gcube/data/access/fs/TestWithLocalContainer.java b/src/test/java/org/gcube/data/access/fs/TestWithLocalContainer.java index bed1e9f..f460392 100644 --- a/src/test/java/org/gcube/data/access/fs/TestWithLocalContainer.java +++ b/src/test/java/org/gcube/data/access/fs/TestWithLocalContainer.java @@ -28,17 +28,14 @@ public class TestWithLocalContainer { @BeforeClass public static void initialize() throws Exception{ + Initializer.setUp(); storagehubUri = new URL(String.format("http://%s:%d/storagehub", "localhost",8081)).toURI(); - /*AccessTokenSecret secret = new AccessTokenSecret("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDQyNDM4ODUsImlhdCI6MTY0NDI0MzU4NSwiYXV0aF90aW1lIjoxNjQ0MjQzNTg1LCJqdGkiOiI1NWQ4ZDc5OS1kNTIzLTQ0YmEtYTRkMC1iZjIyYzVlMTg4NzQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmRldi5kNHNjaWVuY2Uub3JnL2F1dGgvcmVhbG1zL2Q0c2NpZW5jZSIsImF1ZCI6IiUyRmdjdWJlIiwic3ViIjoiNGMxMWRlODQtZGRjOS00ZGQxLWI5N2EtZWE4MmQyZDEzOGE2IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoibmV4dC5kNHNjaWVuY2Uub3JnIiwic2Vzc2lvbl9zdGF0ZSI6ImZkZTA3MGE2LTVkOTUtNDc3Ni1hMTFiLTBhZTI1MzQ5NGQyMyIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiLyoiXSwicmVzb3VyY2VfYWNjZXNzIjp7IiUyRmdjdWJlIjp7InJvbGVzIjpbIkluZnJhc3RydWN0dXJlLU1hbmFnZXIiLCJNZW1iZXIiXX19LCJhdXRob3JpemF0aW9uIjp7InBlcm1pc3Npb25zIjpbeyJyc2lkIjoiMTU5ZDcyMDQtNjlmYS00ZmY0LTlhOTQtMzVlMWUyMzA5MDQyIiwicnNuYW1lIjoiRGVmYXVsdCBSZXNvdXJjZSJ9XX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoiTHVjaW8gTGVsaWkiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJsdWNpby5sZWxpaSIsImdpdmVuX25hbWUiOiJMdWNpbyIsImZhbWlseV9uYW1lIjoiTGVsaWkiLCJlbWFpbCI6Imx1Y2lvLmxlbGlpQGlzdGkuY25yLml0In0.SGuGXnY63WJ45tdypywaopO--FCxY6ZWAX74MGVw_zdNMMQI5zgtGfhZQewFWQ6HhVINDStXqvdSDluhF9JwFXCUGvxB2BipfKQYsAQnm3I4K3kgMl26kuQIL5Im-apw2XWvImTgLshX1AzpyqzFR1Jpf_p65GCMpcHLEwo_nTGLkrZNtfRdtqakZ8S8lowGaV2J2mNf4AHhtARSLJF3GqwynF5pPUXR2iOMUrjw_FLnIuPMfAjk_jHMeYKIxXNBLsoEpELju3pr2gEkv1ZRH9bZkyg7_3hW4mGzxq_Ea9w1FBVJOlkp6vypuISLNyJZcVOnBa4Dg1KRxxlp3aZ6vA"); - SecretManagerProvider.instance.set(secret);*/ client = new StorageHubClient(storagehubUri); createUser(); } @Before public void reset() throws Exception { - /*CredentialSecret secret = new CredentialSecret("sg4-test-client", "a156a7db-3b32-4cd5-b27b-2488e0e01698", "/gcube"); - SecretManagerProvider.instance.set(secret);*/ } private static void createUser() throws Exception{ @@ -55,8 +52,8 @@ public class TestWithLocalContainer { client.impersonate("test.user"); FolderContainer vreFolder = (FolderContainer) client.getVREFolders().getContainers().stream().findFirst().get(); - try(InputStream stream = this.getClass().getResourceAsStream("/output.xlsx")){ - vreFolder.uploadFile(stream, "userTestfile2", "userTestfile" ); + try (InputStream stream = this.getClass().getResourceAsStream("/output.xlsx")) { + vreFolder.uploadFile(stream, "userTestfile2", "userTestfile"); } assertTrue(vreFolder.list().getItems().size()>0);