|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.gcube.contentmanagement.blobstorage.transport.plugin;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
@ -21,7 +22,11 @@ import org.gcube.contentmanagement.blobstorage.service.operation.MoveDir;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.service.operation.Unlock;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.service.operation.Upload;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.plugin.Utils.Utils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
|
|
|
|
@ -50,8 +55,9 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
Region region = Region.US_EAST_1;
|
|
|
|
|
final String END_POINT = "https://s3.wasabisys.com";
|
|
|
|
|
S3Client s3;
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(S3PluginManager.class);
|
|
|
|
|
|
|
|
|
|
// THE FOLLOWING FIELD SHOULD BE RETRIEVED FROM SERVICEENDPOINT
|
|
|
|
|
// THE FOLLOWING FIELDS SHOULD BE RETRIEVED FROM SERVICEENDPOINT
|
|
|
|
|
static final String ACCESS_KEY="UXMKEBMZBDROS5K9HREG";
|
|
|
|
|
static final String SECRET_ACCESS_KEY="0Mqu8gmzcZ09wuqqKZwNmuS5bYC549MlZhvfgv6W";
|
|
|
|
|
static final String bucket="gcube-home-test-access";
|
|
|
|
@ -62,6 +68,12 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
return "S3PluginManager";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public S3PluginManager() {
|
|
|
|
|
logger.info("S3PluginManager");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public S3PluginManager(String[] server, String user, String pass, MemoryType memoryType, String[] dbNames,
|
|
|
|
|
String writeConcern, String readConcern) {
|
|
|
|
|
initBackend(server,user,pass, memoryType,dbNames, writeConcern, readConcern);
|
|
|
|
@ -79,12 +91,14 @@ public class S3PluginManager extends TransportManager {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object get(Download download) throws FileNotFoundException, IOException {
|
|
|
|
|
return BucketOperator.getInstance(s3).getObject(bucket, download.getRemotePath(), download.getLocalPath());
|
|
|
|
|
return BucketOperator.getInstance(s3).getObject(bucket, Utils.convertToS3Format(download.getResource().getRemotePath()), download.getLocalPath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String put(Upload upload) throws FileNotFoundException, IOException {
|
|
|
|
|
return BucketOperator.getInstance(s3).getObject(bucket, upload.getRemotePath(), upload.getLocalPath()).toString();
|
|
|
|
|
logger.info("put method invoked ");
|
|
|
|
|
File file= new File(upload.getResource().getLocalPath());
|
|
|
|
|
return BucketOperator.getInstance(s3).putObject(bucket, Utils.convertToS3Format(upload.getResource().getRemotePath()), file).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|