Compare commits
3 Commits
master
...
porting_to
Author | SHA1 | Date |
---|---|---|
lucio | 697ca73dd7 | |
lucio | b8b4c9bc23 | |
lucio | aacaeea5da |
|
@ -9,6 +9,7 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
<wb-module deploy-name="storagehub-client_TRUNK">
|
<wb-module deploy-name="storagehub-client_TRUNK">
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/test/java"/>
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
|
@ -3,7 +3,13 @@
|
||||||
All notable changes to this project will be documented in this file.
|
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).
|
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
|
### Feature
|
||||||
|
|
||||||
|
|
64
pom.xml
64
pom.xml
|
@ -2,65 +2,41 @@
|
||||||
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>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>maven-parent</artifactId>
|
<artifactId>maven-parent</artifactId>
|
||||||
<groupId>org.gcube.tools</groupId>
|
<groupId>org.gcube.tools</groupId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.0</version>
|
||||||
<relativePath />
|
<relativePath />
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub-client-library.git</connection>
|
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub-client-library.git</connection>
|
||||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub-client-library.git</developerConnection>
|
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub-client-library.git</developerConnection>
|
||||||
<url>https://code-repo.d4science.org/gCubeSystem/storagehub-client-library</url>
|
<url>https://code-repo.d4science.org/gCubeSystem/storagehub-client-library</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<name>storagehub-client-library</name>
|
<name>storagehub-client-library</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>2.1.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.11</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>gov.nih.imagej</groupId>
|
|
||||||
<artifactId>imagej</artifactId>
|
|
||||||
<version>1.47</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-model</artifactId>
|
<artifactId>storagehub-model</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-json-jackson</artifactId>
|
<artifactId>jersey-media-json-jackson</artifactId>
|
||||||
|
@ -69,7 +45,6 @@
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-multipart</artifactId>
|
<artifactId>jersey-media-multipart</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-gcube-calls</artifactId>
|
<artifactId>common-gcube-calls</artifactId>
|
||||||
|
@ -77,21 +52,37 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>common-jaxrs-client</artifactId>
|
<artifactId>common-jaxrs-client</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-generic-clients</artifactId>
|
<artifactId>common-generic-clients</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.ws</groupId>
|
||||||
|
<artifactId>rt</artifactId>
|
||||||
|
<version>2.3.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common.security</groupId>
|
||||||
|
<artifactId>gcube-secrets</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -115,6 +106,11 @@
|
||||||
<version>5.3</version>
|
<version>5.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>gov.nih.imagej</groupId>
|
||||||
|
<artifactId>imagej</artifactId>
|
||||||
|
<version>1.47</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -53,6 +53,10 @@ public class VREFolderManager {
|
||||||
groupClient.createGroup(vreTitle, accessType, folderOwner);
|
groupClient.createGroup(vreTitle, accessType, folderOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createVRE(AccessType accessType, String folderOwner, boolean useDefaultStorage) throws StorageHubException{
|
||||||
|
groupClient.createGroup(vreTitle, accessType, folderOwner, useDefaultStorage);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeVRE() throws StorageHubException{
|
public void removeVRE() throws StorageHubException{
|
||||||
groupClient.removeGroup(vreTitle);
|
groupClient.removeGroup(vreTitle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DefaultGroupManager extends DefaultManagerClient implements GroupMa
|
||||||
else if (response.getHTTPCode()==403)
|
else if (response.getHTTPCode()==403)
|
||||||
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError("response is "+response.getHTTPCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,6 +160,11 @@ public class DefaultGroupManager extends DefaultManagerClient implements GroupMa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createGroup(String groupId, AccessType accessType, String folderOwner) throws StorageHubException {
|
public void createGroup(String groupId, AccessType accessType, String folderOwner) throws StorageHubException {
|
||||||
|
this.createGroup(groupId, accessType, folderOwner, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createGroup(String groupId, AccessType accessType, String folderOwner, boolean useDefaultStorage) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, Void> call = new Call<GXWebTargetAdapterRequest, Void>() {
|
Call<GXWebTargetAdapterRequest, Void> call = new Call<GXWebTargetAdapterRequest, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
@ -169,7 +174,7 @@ public class DefaultGroupManager extends DefaultManagerClient implements GroupMa
|
||||||
multipart.field("accessType", accessType, MediaType.APPLICATION_JSON_TYPE);
|
multipart.field("accessType", accessType, MediaType.APPLICATION_JSON_TYPE);
|
||||||
multipart.field("group", groupId);
|
multipart.field("group", groupId);
|
||||||
multipart.field("folderOwner", folderOwner);
|
multipart.field("folderOwner", folderOwner);
|
||||||
|
multipart.field("useDefaultStorage", Boolean.toString(useDefaultStorage));
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
GXInboundResponse response = myManager.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ public interface GroupManagerClient extends ManagerClient{
|
||||||
|
|
||||||
void createGroup(String groupId, AccessType accessType, String folderOwner) throws StorageHubException;
|
void createGroup(String groupId, AccessType accessType, String folderOwner) throws StorageHubException;
|
||||||
|
|
||||||
|
void createGroup(String groupId, AccessType accessType, String folderOwner, boolean useDefaultStorage) throws StorageHubException;
|
||||||
|
|
||||||
List<String> getUsersOfGroup(String groupId) throws StorageHubException;
|
List<String> getUsersOfGroup(String groupId) throws StorageHubException;
|
||||||
|
|
||||||
List<String> getGroups() throws StorageHubException;
|
List<String> getGroups() throws StorageHubException;
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
package org.gcube.data.access.fs;
|
package org.gcube.data.access.fs;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
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.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;
|
||||||
|
@ -20,29 +15,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class ImportTest {
|
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
|
@Test
|
||||||
|
@ -58,7 +31,7 @@ public class ImportTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importTest(String folderId, String relativePath) throws Exception {
|
public void importTest(String folderId, String relativePath) throws Exception {
|
||||||
setUp(prodEnv);
|
Initializer.setUp();
|
||||||
|
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
FolderContainer fc = shc.open(folderId).asFolder();
|
FolderContainer fc = shc.open(folderId).asFolder();
|
||||||
|
@ -68,10 +41,10 @@ public class ImportTest {
|
||||||
for (ItemContainer<? extends Item> itemContainer : items) {
|
for (ItemContainer<? extends Item> itemContainer : items) {
|
||||||
if (itemContainer.getType() == ContainerType.FOLDER) {
|
if (itemContainer.getType() == ContainerType.FOLDER) {
|
||||||
new Thread(()-> createInDev(itemContainer.get(), itemContainer.getType(), relativePath, null)).run();
|
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() );
|
importTest(itemContainer.getId(), relativePath == null ? itemContainer.get().getName() : relativePath+"/"+itemContainer.get().getName() );
|
||||||
} else if (itemContainer.getType() == ContainerType.FILE){
|
} else if (itemContainer.getType() == ContainerType.FILE){
|
||||||
setUp(prodEnv);
|
Initializer.setUp();
|
||||||
final URL publicLink = ((FileContainer)itemContainer).getPublicLink();
|
final URL publicLink = ((FileContainer)itemContainer).getPublicLink();
|
||||||
System.out.println("publik Link "+publicLink.toString());
|
System.out.println("publik Link "+publicLink.toString());
|
||||||
new Thread(()-> createInDev(itemContainer.get(), itemContainer.getType(), relativePath, publicLink)).run();
|
new Thread(()-> createInDev(itemContainer.get(), itemContainer.getType(), relativePath, publicLink)).run();
|
||||||
|
@ -83,7 +56,7 @@ public class ImportTest {
|
||||||
|
|
||||||
|
|
||||||
public <T extends Item> void createInDev(T item, ContainerType type, String relativePath, URL publicLink){
|
public <T extends Item> void createInDev(T item, ContainerType type, String relativePath, URL publicLink){
|
||||||
setUp(devEnv);
|
Initializer.setUp();
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
try {
|
try {
|
||||||
FolderContainer currentFolder = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
|
FolderContainer currentFolder = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
|
||||||
|
|
|
@ -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";
|
||||||
|
private static final String devRoot = "dev-root";
|
||||||
|
|
||||||
|
|
||||||
|
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(devRoot);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,11 +14,8 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
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.StreamDescriptor;
|
||||||
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;
|
||||||
|
@ -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.Metadata;
|
||||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
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.FolderItem;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -42,36 +38,15 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class Items {
|
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
|
@BeforeClass
|
||||||
public static void setUp(){
|
public static void setUp(){
|
||||||
|
Initializer.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addUserToVRe() throws StorageHubException {
|
public void addUserToVRe() throws StorageHubException {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
|
|
||||||
String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt";
|
String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt";
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File(vresFile))){
|
try(InputStream is = new FileInputStream(new File(vresFile))){
|
||||||
|
@ -97,6 +72,14 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void opeVREfolder() throws StorageHubException{
|
||||||
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
//shc.openVREFolder();
|
||||||
|
shc.getVreFolderManager("gcube-devsec-devVRE").setAdmin("massimiliano.assante");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeVersion() throws Exception {
|
public void removeVersion() throws Exception {
|
||||||
|
|
|
@ -4,18 +4,14 @@ import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
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
|
//code-repo.d4science.org/gCubeSystem/storagehub-client-library.git
|
||||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
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 Logger log = LoggerFactory.getLogger(TestCall.class);
|
||||||
|
|
||||||
private static final String propFile = "/home/lucio/tokens.properties";
|
|
||||||
|
|
||||||
private static final String tokens = "dev-root";
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp(){
|
public static void setUp(){
|
||||||
|
Initializer.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,17 +28,14 @@ public class TestWithLocalContainer {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initialize() throws Exception{
|
public static void initialize() throws Exception{
|
||||||
|
Initializer.setUp();
|
||||||
storagehubUri = new URL(String.format("http://%s:%d/storagehub", "localhost",8081)).toURI();
|
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);
|
client = new StorageHubClient(storagehubUri);
|
||||||
createUser();
|
createUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void reset() throws Exception {
|
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{
|
private static void createUser() throws Exception{
|
||||||
|
@ -55,8 +52,8 @@ public class TestWithLocalContainer {
|
||||||
|
|
||||||
client.impersonate("test.user");
|
client.impersonate("test.user");
|
||||||
FolderContainer vreFolder = (FolderContainer) client.getVREFolders().getContainers().stream().findFirst().get();
|
FolderContainer vreFolder = (FolderContainer) client.getVREFolders().getContainers().stream().findFirst().get();
|
||||||
try(InputStream stream = this.getClass().getResourceAsStream("/output.xlsx")){
|
try (InputStream stream = this.getClass().getResourceAsStream("/output.xlsx")) {
|
||||||
vreFolder.uploadFile(stream, "userTestfile2", "userTestfile" );
|
vreFolder.uploadFile(stream, "userTestfile2", "userTestfile");
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(vreFolder.list().getItems().size()>0);
|
assertTrue(vreFolder.list().getItems().size()>0);
|
||||||
|
|
Loading…
Reference in New Issue