|
|
|
@ -6,10 +6,10 @@ import java.io.IOException;
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.service.operation.Copy;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.service.operation.CopyDir;
|
|
|
|
@ -49,8 +49,9 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
Region region = Region.EU_NORTH_1;
|
|
|
|
|
// final String END_POINT = "https://s3.wasabisys.com";
|
|
|
|
|
static String bucket="g3-test1data"; // gcube-test;//"gcube-home-test-access";
|
|
|
|
|
private String token;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return "S3";
|
|
|
|
@ -63,55 +64,49 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public S3PluginManager(String[] server, String user, String pass, MemoryType memoryType, String[] dbNames,
|
|
|
|
|
String writeConcern, String readConcern) {
|
|
|
|
|
initBackend(server,user,pass, memoryType,dbNames, writeConcern, readConcern);
|
|
|
|
|
String writeConcern, String readConcern, String token, String region) {
|
|
|
|
|
initBackend(server,user,pass, memoryType,dbNames, writeConcern, readConcern, token, region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initBackend(String[] server, String accessKey, String secretAccessKey, MemoryType memoryType, String[] dbNames,
|
|
|
|
|
String writeConcern, String readConcern) {
|
|
|
|
|
// AwsSessionCredentials awsCreds = AwsSessionCredentials.create(ACCESS_KEY, SECRET_ACCESS_KEY, "");
|
|
|
|
|
AwsSessionCredentials awsCreds = AwsSessionCredentials.create(accessKey, secretAccessKey, "");
|
|
|
|
|
// s3 = S3Client.builder().credentialsProvider(
|
|
|
|
|
// StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
// .endpointOverride(URI.create(END_POINT)).region(region).build();
|
|
|
|
|
// region=Region.of(dbNames[0]);
|
|
|
|
|
// region=Region.of("The Netherlands");
|
|
|
|
|
// logger.debug("connection to region: "+region);
|
|
|
|
|
region = Region.of("eu-nl");
|
|
|
|
|
String writeConcern, String readConcern, String token, String region) {
|
|
|
|
|
|
|
|
|
|
AwsSessionCredentials awsCreds =null;
|
|
|
|
|
if(!Objects.isNull(getToken()))
|
|
|
|
|
awsCreds = AwsSessionCredentials.create(accessKey, secretAccessKey, token);
|
|
|
|
|
else
|
|
|
|
|
awsCreds = AwsSessionCredentials.create(accessKey, secretAccessKey, "");
|
|
|
|
|
this.region = Region.of(region);
|
|
|
|
|
s3 = S3Client.builder().credentialsProvider(
|
|
|
|
|
StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
.endpointOverride(URI.create(server[0])).region(region).build();
|
|
|
|
|
// without region specification
|
|
|
|
|
// s3 = S3Client.builder().credentialsProvider(
|
|
|
|
|
// StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
// .endpointOverride(URI.create(server[0])).build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.endpointOverride(URI.create(server[0])).region(this.region).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
public void initBackendzad(String[] server, String accessKey, String secretAccessKey, MemoryType memoryType, String[] dbNames,
|
|
|
|
|
String writeConcern, String readConcern) {
|
|
|
|
|
region = Region.of("IT");
|
|
|
|
|
// AwsSessionCredentials awsCreds = AwsSessionCredentials.create(accessKey, secretAccessKey, "");
|
|
|
|
|
AwsSessionCredentials awsCreds = AwsSessionCredentials.create("1168063577b54b30bd35e9ed209e698e", "e60be85b39dc4e1e816f6d922c1f2c3a", "gAAAAABf3MQXCVgepxjLLPAaPb063qABbuMVERNoW7CrQgQpu-Phea-YG1aQEhBwbnQZqkAZMUfI3DaMbFdCPZ7sTJn2RY3hwP8y1qBQmt5oRTxJAHO01JdLcTAOtBLH7et1KPdo-AOLvuwWclYYI2nvztqeT2FhNK5irTY004tm_1pgwvuHRfE");
|
|
|
|
|
// s3 = S3Client.builder().region(newRegion)
|
|
|
|
|
// .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
// .httpClientBuilder(ApacheHttpClient.builder().connectionTimeout(Duration.ofSeconds(30))
|
|
|
|
|
// .connectionMaxIdleTime(Duration.ofSeconds(30)).socketTimeout(Duration.ofSeconds(60)));
|
|
|
|
|
// s3 = s3.endpointOverride(new URI("http://xxxxxxx"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s3 = S3Client.builder().credentialsProvider(
|
|
|
|
|
StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
.endpointOverride(URI.create("https://vsa-0000000e-it-momit-01.zadarazios.com:443")).region(region).build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//// @Override
|
|
|
|
|
// public void initBackendzad(String[] server, String accessKey, String secretAccessKey, MemoryType memoryType, String[] dbNames,
|
|
|
|
|
// String writeConcern, String readConcern) {
|
|
|
|
|
//// region = Region.of("IT");
|
|
|
|
|
// region = Region.of(dbNames[0]);
|
|
|
|
|
// String hardcodedToken="gAAAAABf3MQXCVgepxjLLPAaPb063qABbuMVERNoW7CrQgQpu-Phea-YG1aQEhBwbnQZqkAZMUfI3DaMbFdCPZ7sTJn2RY3hwP8y1qBQmt5oRTxJAHO01JdLcTAOtBLH7et1KPdo-AOLvuwWclYYI2nvztqeT2FhNK5irTY004tm_1pgwvuHRfE";
|
|
|
|
|
//// AwsSessionCredentials awsCreds = AwsSessionCredentials.create(accessKey, secretAccessKey, "");
|
|
|
|
|
// AwsSessionCredentials awsCreds = AwsSessionCredentials.create("1168063577b54b30bd35e9ed209e698e", "e60be85b39dc4e1e816f6d922c1f2c3a", token);
|
|
|
|
|
//// s3 = S3Client.builder().region(newRegion)
|
|
|
|
|
//// .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
//// .httpClientBuilder(ApacheHttpClient.builder().connectionTimeout(Duration.ofSeconds(30))
|
|
|
|
|
//// .connectionMaxIdleTime(Duration.ofSeconds(30)).socketTimeout(Duration.ofSeconds(60)));
|
|
|
|
|
//// s3 = s3.endpointOverride(new URI("http://xxxxxxx"));
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// s3 = S3Client.builder().credentialsProvider(
|
|
|
|
|
// StaticCredentialsProvider.create(awsCreds))
|
|
|
|
|
// .endpointOverride(URI.create("https://vsa-0000000e-it-momit-01.zadarazios.com:443")).region(region).build();
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -133,24 +128,24 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, StorageObject> getValues(MyFile resource, String bucket, Class<? extends Object> type) {
|
|
|
|
|
public Map<String, StorageObject> getValues(RequestObject resource, String bucket, Class<? extends Object> type) {
|
|
|
|
|
throw new RemoteBackendException("method not implemented yet on s3 plugin");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void removeRemoteFile(String bucket, MyFile resource) throws UnknownHostException {
|
|
|
|
|
public void removeRemoteFile(String bucket, RequestObject resource) throws UnknownHostException {
|
|
|
|
|
BucketOperator.getInstance(s3).deleteObject(this.bucket, Utils.convertToS3Format(resource.getRemotePath()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void removeDir(String remoteDir, MyFile myFile) throws UnknownHostException {
|
|
|
|
|
public void removeDir(String remoteDir, RequestObject myFile) throws UnknownHostException {
|
|
|
|
|
throw new RemoteBackendException("method not implemented yet on s3 plugin");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long getSize(String key, MyFile file) {
|
|
|
|
|
public long getSize(String key, RequestObject file) {
|
|
|
|
|
logger.info("remoteObject identifier "+key);
|
|
|
|
|
try {
|
|
|
|
|
return BucketOperator.getObjectSize(Utils.convertToS3Format(file.getRootPath()), Utils.convertToS3Format(file.getRemotePath()));
|
|
|
|
@ -176,7 +171,7 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long renewTTL(MyFile resource) throws UnknownHostException, IllegalAccessException {
|
|
|
|
|
public long renewTTL(RequestObject resource) throws UnknownHostException, IllegalAccessException {
|
|
|
|
|
throw new RemoteBackendException("method not implemented yet on s3 plugin");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -272,5 +267,13 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
throw new RemoteBackendException("method not implemented yet on s3 plugin");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected String getToken() {
|
|
|
|
|
return token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void setToken(String token) {
|
|
|
|
|
this.token = token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|