Merge branch 'master' into v3.0.1-SNAP

This commit is contained in:
Roberto Cirillo 2021-11-19 10:05:59 +01:00
commit 7fd4e6c0c1
12 changed files with 192 additions and 24 deletions

View File

@ -6,24 +6,21 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <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,12 +1,13 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -12,10 +12,14 @@
* fix JUnitTests * fix JUnitTests
* upgrade JUnit to 4.12 * upgrade JUnit to 4.12
## [v2.6.0-SNAPSHOT] 2020-11-12 ## [v3.0.0] 2021-09-10
* bug fix #20505
* update gcub-bom version
* Change serviceEndpoint Category from DataStorage to Storage
* bugfix #20505
* adding new constructor with the backendType as input parameter * adding new constructor with the backendType as input parameter
* retrieving specific backend credentials if a specific backend si specified as input parameter * retrieving specific backend credentials if a specific backend si specified as input parameter
* moved from 2.6.1 to 3.0.0-SNAPSHOT
## [v2.5.3] 2019-03-20 ## [v2.5.3] 2019-03-20
* Added wrapper for HomeLibrary configuration related to the new preproduction infrastructure * Added wrapper for HomeLibrary configuration related to the new preproduction infrastructure

View File

@ -22,7 +22,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId> <artifactId>gcube-bom</artifactId>
<version>1.4.0</version> <version>2.0.1</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -62,6 +62,10 @@
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>

View File

@ -58,8 +58,8 @@ public class Configuration {
private static final String HL_CONTEXT = "/d4science.research-infrastructures.eu"; private static final String HL_CONTEXT = "/d4science.research-infrastructures.eu";
private static final String HL_CONTEXT_DEV = "/gcube"; private static final String HL_CONTEXT_DEV = "/gcube";
private static final String HL_CONTEXT_PRE = "/pred4s"; private static final String HL_CONTEXT_PRE = "/pred4s";
protected static final String STORAGE_SERVICEENDPOINT_NAME="StorageManager";
protected static final String STORAGE_SERVICEENDPOINT_CATEGORY="Storage";
/** /**
* Loads all the configuration parameters in a java object * Loads all the configuration parameters in a java object
* @param sc: service class of the remote resource * @param sc: service class of the remote resource

View File

@ -102,6 +102,7 @@ public class ISClientConnector {
private String[] fillConnectionFields(ServiceEndpoint resource) { private String[] fillConnectionFields(ServiceEndpoint resource) {
logger.debug("fillConnectionsFields method "); logger.debug("fillConnectionsFields method ");
if(resource!=null){ if(resource!=null){
<<<<<<< HEAD
logger.debug("checking resource "+resource.id()); logger.debug("checking resource "+resource.id());
ArrayList<String> server=new ArrayList<String> ();//new String[resource.profile().accessPoints().size()]; ArrayList<String> server=new ArrayList<String> ();//new String[resource.profile().accessPoints().size()];
if(!(getBackendType().equals(BackendType.MongoDB.name()))) { if(!(getBackendType().equals(BackendType.MongoDB.name()))) {
@ -133,6 +134,25 @@ public class ISClientConnector {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
=======
ArrayList<String> srvs=new ArrayList <String>();
// String [] server=new String[resource.profile().accessPoints().size()];
int i=0;
for (AccessPoint ap:resource.profile().accessPoints()) {
if (ap.name().equals("server"+(i+1))) {
// server[i] = ap.address();
srvs.add(ap.address());
// if presents, try to get user and password
setUsername(ap.username());
// set password default value to empty string
setPassword("");
if(getUsername() != null && getUsername().length() > 0){
try {
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
>>>>>>> master
} }
i++; i++;
} }
@ -140,7 +160,13 @@ public class ISClientConnector {
logger.info("credentials Mongodb: "+getUsername()+" "+getPassword()); logger.info("credentials Mongodb: "+getUsername()+" "+getPassword());
// setBackendType(retrievePropertyValue(resource, "type")); // setBackendType(retrievePropertyValue(resource, "type"));
} }
<<<<<<< HEAD
=======
String [] server=new String[srvs.size()];
server = srvs.toArray(server);
setBackendType(retrievePropertyValue(resource, "type"));
>>>>>>> master
String [] volatileHost= new String [1]; String [] volatileHost= new String [1];
volatileHost[0]=retrievePropertyValue(resource, "volatile"); volatileHost[0]=retrievePropertyValue(resource, "volatile");
setVolatileHost(volatileHost); setVolatileHost(volatileHost);
@ -303,4 +329,4 @@ public class ISClientConnector {
} }
} }

View File

@ -39,8 +39,13 @@ public class DownloadsTest {
private static String id1; private static String id1;
private String encryptedId="OE5tOCtuTUt5eXVNd3JkRDlnRFpDY1h1MVVWaTg0cUtHbWJQNStIS0N6Yz0";//"SG1EN2JFNXIELzZ1czdsSkRIa0Evd3VzcGFHU3J6L2RHbWJQNStIS0N6Yz0";//"OE5tOCtuTUt5eXVNd3JkRDlnRFpDY1h1MVVWaTg0cUtHbWJQNStIS0N6Yz0";//"SThtL0xRU281M2UzY29ldE44SkhkbzVkMlBWVmM4aEJHbWJQNStIS0N6Yz0";//"dExaYzNKelNyQVZMemxpcXplVXYzZGN4OGZTQ2w4aU5HbWJQNStIS0N6Yz0";//"Mm9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HbWJQNStIS0N6Yz0";//"dExaYzNKelNyQVZMemxpcXplVXYzZGN4OGZTQ2w4aU5HbWJQNStIS0N6Yz0";//"Mm9nc0tZbXR1TVI2cVRxL3pVUElrRXJkbk9vVDY2eEJHbWJQNStIS0N6Yz0";//"FemRmUEFtRGVZMnozcEdBekVHU3E4Skt5dkh2OXJObHFHbWJQNStIS0N6Yz0";//"L0p3OGJjUHhFaEJoTmppdjlsK0l0Z0h1b3VpVlloUzVHbWJQNStIS0N6Yz0";//"NWJTRFdxQkQxclJHV05FbExrRDJjL0g4QTBwSnV1TVdHbWJQNStIS0N6Yz0";//"M2JIM2hqNUNyRkxBdG00cnRaWDBpUGxRTmtVQmtEdXBHbWJQNStIS0N6Yz0";//"lfV6BqnBWUbN5dUiQ6xpkMgI69wEwcm6Ygh60bFzaL3h2Run5e9uZMoTix+ykL5H";//"huivj74/QCHnj376YGe/FicgYHSHcwph7SoMty7FBmAh+80AzGQtOdanne6zJBd5";//"lfV6BqnBWUbN5dUiQ6xpkMgI69wEwcm6Ygh60bFzaL3h2Run5e9uZMoTix+ykL5H";//"bksxMGVWTlZ3WjM5Z1ZXYXlUOUtMZzVSNlBhZXFGb05HbWJQNStIS0N6Yz0";//"bEVydmtsOHhCclZMZGd4cEtnTVQzZXQ5UVNxWHZURGJHbWJQNStIS0N6Yz0";//"bEVydmtsOHhCclZMZGd4cEtnTVQz";//"cHEvek1sbjdBaWJkc0s4SzZpSUJpU0c2ZEgyOEVyUGJHbWJQNStIS0N6Yz0";//"RnpoMy9ZaVRoRkZjbk8ybGx0QnlRR";//"L1pWTlV3ZWxPbHRyMloxZ0JnWUVHdHYvUnZDVHJiMTBHbWJQNStIS0N6Yz0";
<<<<<<< HEAD
@BeforeClass @BeforeClass
public static void getClient() throws RemoteBackendException{ public static void getClient() throws RemoteBackendException{
=======
@Before
public void getClient() throws RemoteBackendException{
>>>>>>> master
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING); ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
// ScopeProvider.instance.set(scope); // ScopeProvider.instance.set(scope);
try { try {
@ -61,7 +66,7 @@ public class DownloadsTest {
} }
@Test // @Test
public void getId(){ public void getId(){
String id= client.getId(encryptedId); String id= client.getId(encryptedId);
System.out.println("id decrypted: "+id); System.out.println("id decrypted: "+id);

View File

@ -0,0 +1,125 @@
package org.gcube.contentmanager.storageclient.test;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ForceCloseTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica.jpg";
private String localPath2="src/test/resources/dog.jpg";
private String localPathDownload="src/test/resources/download.png";
private String remotePath="/test/test-resources/CostaRica1.jpg";
private String absoluteLocalPath;
private String absoluteLocalPath2;
private String absoluteLocalPathDownload;
private String newFilePath="src/test/resources";
private String remoteDirPath= "test/test-forceclose";
private IClient client;
private String serviceClass="JUnitTest-ForceCloseTest";
private String serviceName="StorageManager";
private static final Logger logger = LoggerFactory.getLogger(ForceCloseTest.class);
@Before
public void getClient(){
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setLocalResources();
//upload costaRica
String id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
System.out.println("UploadByPath id: "+id);
assertNotNull(id);
}
@Test
public void forceCloseTest(){
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
client.forceClose();
//download
try {
client.get().LFile(absoluteLocalPathDownload).RFile(remotePath);
}catch(Exception e ) {
assertNotNull(e);
}
// try {
// client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
// assertNotNull(client);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// delete
removeRemoteFile();
client.forceClose();
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@After
public void removeLocalFile(){
File f=new File(newFilePath);
f.delete();
assertFalse(f.exists());
}
private void removeRemoteFile() throws RemoteBackendException{
List<StorageObject> list = printDir(remoteDirPath);
client.remove().RFile(remotePath);
list = printDir(remoteDirPath);
assertTrue(list.isEmpty());
}
private List<StorageObject> printDir(String dir) {
List<StorageObject> list=client.showDir().RDir(dir);
for(StorageObject obj : list){
System.out.println("found "+obj.getName()+" and id " +obj.getId());
}
return list;
}
private void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/testJunit.jpg";
absoluteLocalPath=new File(localPath).getAbsolutePath();
absoluteLocalPath2=new File(localPath2).getAbsolutePath();
absoluteLocalPathDownload=new File(localPathDownload).getAbsolutePath();
}
}

View File

@ -39,10 +39,10 @@ public class HLcheckTest {
@Before @Before
public void getClient() throws RemoteBackendException{ public void getClient() throws RemoteBackendException{
// ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING); ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
ScopeProvider.instance.set(scope); // ScopeProvider.instance.set(scope);
try { try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, scope, false).getClient(); client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_SCOPE_STRING, false).getClient();
assertNotNull(client); assertNotNull(client);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -88,13 +88,19 @@ public class HLcheckTest {
@Test @Test
public void downloadBySpecificIdOnlyForTest() throws RemoteBackendException{ public void downloadBySpecificIdOnlyForTest() throws RemoteBackendException{
<<<<<<< HEAD
// String idReturned=client.get().LFile(newFilePath).RFileById(id); // String idReturned=client.get().LFile(newFilePath).RFileById(id);
// String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip"; // String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
String file="/Users/roberto/VivianaOtero/detailed_simulation_4327.csv"; String file="/Users/roberto/VivianaOtero/detailed_simulation_4327.csv";
String idReturned=client.get().LFile(file).RFile("60830489d56b08199c3407c6"); String idReturned=client.get().LFile(file).RFile("60830489d56b08199c3407c6");
=======
String idReturned=client.get().LFile(newFilePath).RFileById(id);
// String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
// String idReturned=client.get().LFile(absoluteLocalPath).RFile("5f6a1f405b0bde3544cbd3be");
>>>>>>> master
System.out.println("downloadById id: "+idReturned); System.out.println("downloadById id: "+idReturned);
// File f =new File(newFilePath); File f =new File(newFilePath);
File f =new File(file); // File f =new File(file);
System.out.println("path new File downloaded: "+f.getAbsolutePath()); System.out.println("path new File downloaded: "+f.getAbsolutePath());
assertTrue(f.exists()); assertTrue(f.exists());
removeLocalFile(); removeLocalFile();

View File

@ -52,7 +52,7 @@ public class LockTest {
assertNotNull(id); assertNotNull(id);
} }
@Test // @Test
public void lockTest(){ public void lockTest(){
//download & lock //download & lock
String idLock=client.lock().LFile(absoluteLocalPathDownload).RFile(remotePath); String idLock=client.lock().LFile(absoluteLocalPathDownload).RFile(remotePath);

View File

@ -50,8 +50,8 @@ public class UrlResolverTest {
} }
@Test @Test
public void getHttpUrl() throws RemoteBackendException { public void getHttpsUrl() throws RemoteBackendException {
String url=client.getHttpUrl().RFile(remotePath); String url=client.getHttpsUrl().RFile(remotePath);
System.out.println("HttpUrl generated: "+url); System.out.println("HttpUrl generated: "+url);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 346 KiB