bug fix 22164; clean code.
This commit is contained in:
parent
5a644f79a0
commit
15a4909d7c
|
@ -1,6 +1,7 @@
|
|||
# Changelog for storage-manager-core
|
||||
|
||||
## [v3.0.0] 2021-09-10
|
||||
* fix #22164
|
||||
* fix #21980
|
||||
* update gcube-bom version
|
||||
* add close operation on IClient interface
|
||||
|
|
|
@ -38,8 +38,6 @@ public abstract class Copy extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.OutputStream;
|
|||
|
||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.DownloadOperator;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -40,8 +39,6 @@ public class DownloadAndLock extends Operation {
|
|||
//TODO add field for file lock
|
||||
get(download,myFile, true);
|
||||
} catch (Exception e) {
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in downloadAndLock operation ", e.getCause());
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.bson.types.ObjectId;
|
|||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.BucketCoding;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -31,8 +30,6 @@ public abstract class DuplicateFile extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
|
|
|
@ -31,8 +31,6 @@ public class Exist extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
boolean isPresent=false;
|
||||
try {
|
||||
|
|
|
@ -23,12 +23,7 @@ public class FileWriter extends Thread{
|
|||
final Logger logger=LoggerFactory.getLogger(FileWriter.class);
|
||||
private Monitor monitor;
|
||||
private int id;
|
||||
// private MyFile myFile;
|
||||
// private byte[] encode;
|
||||
// private int offset;
|
||||
// private static int len=0;
|
||||
private OutputStream out;
|
||||
// private String path;
|
||||
private byte[] full;
|
||||
|
||||
|
||||
|
|
|
@ -13,15 +13,12 @@ public class ForceClose extends Operation{
|
|||
* Logger for this class
|
||||
*/
|
||||
final Logger logger=LoggerFactory.getLogger(GetSize.class);
|
||||
// public String file_separator = ServiceEngine.FILE_SEPARATOR;//System.getProperty("file.separator");
|
||||
|
||||
public ForceClose(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
tm.forceClose();
|
||||
|
|
|
@ -23,8 +23,6 @@ public class GetFolderCount extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
try {
|
||||
|
|
|
@ -22,8 +22,6 @@ public class GetFolderSize extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,12 @@ import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
|||
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
|
||||
/**
|
||||
* this class is replaced by getHttpsUrl
|
||||
* @author roberto
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class GetHttpUrl extends Operation {
|
||||
|
||||
|
@ -46,7 +52,8 @@ public class GetHttpUrl extends Operation {
|
|||
String urlBase="smp://"+resolverHost+Costants.URL_SEPARATOR;
|
||||
String urlParam="";
|
||||
try {
|
||||
String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
String id=getId(myFile);
|
||||
String phrase=myFile.getPassPhrase();
|
||||
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
|
||||
urlParam = new Encrypter("DES", phrase).encrypt(id);
|
||||
|
@ -71,7 +78,7 @@ public class GetHttpUrl extends Operation {
|
|||
return httpUrl.toString();
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
|
@ -87,6 +94,21 @@ public class GetHttpUrl extends Operation {
|
|||
return id;
|
||||
}
|
||||
|
||||
private String getId(MyFile myFile){
|
||||
String id=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
id = tm.getId(bucket, myFile.isForceCreation());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" PATH " + bucket);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
private URL translate(URL url) throws IOException {
|
||||
logger.debug("translating: "+url);
|
||||
String urlString=url.toString();
|
||||
|
|
|
@ -48,7 +48,8 @@ public class GetHttpsUrl extends Operation {
|
|||
String urlBase="smp://"+resolverHost+Costants.URL_SEPARATOR;
|
||||
String urlParam="";
|
||||
try {
|
||||
String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
String id=getId(myFile);
|
||||
String phrase=myFile.getPassPhrase();
|
||||
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
|
||||
urlParam = new Encrypter("DES", phrase).encrypt(id);
|
||||
|
@ -73,6 +74,21 @@ public class GetHttpsUrl extends Operation {
|
|||
return httpsUrl.toString();
|
||||
}
|
||||
|
||||
private String getId(MyFile myFile){
|
||||
String id=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
id = tm.getId(bucket, myFile.isForceCreation());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" PATH " + bucket);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
|
|
|
@ -31,8 +31,6 @@ public class GetMetaFile extends Operation{
|
|||
*
|
||||
*/
|
||||
public MyFile doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
String id=null;
|
||||
|
|
|
@ -21,8 +21,6 @@ public class GetMetaInfo extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String value=null;
|
||||
try {
|
||||
|
|
|
@ -21,8 +21,6 @@ public class GetRemotePath extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String path=null;
|
||||
try {
|
||||
|
|
|
@ -28,8 +28,6 @@ public class GetSize extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
try {
|
||||
|
|
|
@ -36,8 +36,6 @@ public class GetTTL extends Operation {
|
|||
TransportManager tm=null;
|
||||
try {
|
||||
//aggiungere field per il lock del file
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
tm=getTransport(myFile);
|
||||
currentTTL=tm.getTTL(bucket);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -9,8 +9,12 @@ import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory
|
|||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* this class is replaced by getHttpsUrl
|
||||
* @author roberto
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class GetUrl extends Operation{
|
||||
|
||||
// private OutputStream os;
|
||||
|
@ -40,11 +44,10 @@ public class GetUrl extends Operation{
|
|||
String urlBase="smp://"+resolverHost+Costants.URL_SEPARATOR;
|
||||
String urlParam="";
|
||||
try {
|
||||
String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
String id=getId(myFile);
|
||||
String phrase=myFile.getPassPhrase();
|
||||
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
|
||||
urlParam = new Encrypter("DES", phrase).encrypt(id);
|
||||
// String urlEncoded=URLEncoder.encode(urlParam, "UTF-8");
|
||||
} catch (EncryptionException e) {
|
||||
throw new RemoteBackendException(" Error in getUrl operation problem to encrypt the string", e.getCause());
|
||||
}
|
||||
|
@ -56,6 +59,7 @@ public class GetUrl extends Operation{
|
|||
return url;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
|
@ -71,4 +75,18 @@ public class GetUrl extends Operation{
|
|||
return id;
|
||||
}
|
||||
|
||||
private String getId(MyFile myFile){
|
||||
String id=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
id = tm.getId(bucket, myFile.isForceCreation());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" PATH " + bucket);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ public class GetUserTotalItems extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String dim=null;
|
||||
logger.info("check user total items for user: "+getOwner()+ " user is "+user);
|
||||
|
|
|
@ -13,15 +13,12 @@ import org.slf4j.LoggerFactory;
|
|||
public class GetUserTotalVolume extends Operation {
|
||||
|
||||
final Logger logger=LoggerFactory.getLogger(GetUserTotalVolume.class);
|
||||
// public String file_separator = ServiceEngine.FILE_SEPARATOR;//System.getProperty("file.separator");
|
||||
|
||||
public GetUserTotalVolume(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String dim=null;
|
||||
logger.info("check user total volume for user: "+getOwner()+ " user is "+user);
|
||||
|
|
|
@ -37,8 +37,6 @@ public abstract class Link extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
|
|
|
@ -44,8 +44,6 @@ public abstract class Lock extends Operation {
|
|||
Download download = new DownloadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||
unlockKey=get(download, myFile, true);
|
||||
} catch (Exception e) {
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in lock operation ", e.getCause());
|
||||
|
|
|
@ -40,12 +40,9 @@ public abstract class Move extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
// id=tm.move(myFile, sourcePath, destinationPath);
|
||||
id=tm.move(this);
|
||||
} catch (UnknownHostException e) {
|
||||
tm.close();
|
||||
|
|
|
@ -39,8 +39,6 @@ public abstract class MoveDir extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
List<String>ids=null;
|
||||
try {
|
||||
|
|
|
@ -161,8 +161,6 @@ public abstract class Operation {
|
|||
}else{
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("NO THREAD POOL USED");
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
|
||||
TransportManager tm=getTransport(resource);
|
||||
String objectId=tm.uploadManager(upload, resource, bucket, bucket+"_1", replaceOption);
|
||||
return objectId;
|
||||
|
@ -180,9 +178,6 @@ public abstract class Operation {
|
|||
logger.debug("get(String) - start");
|
||||
}
|
||||
String unlocKey=null;
|
||||
// TransportManagerFactory tmf=null;
|
||||
// tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long start=System.currentTimeMillis();
|
||||
String path=myFile.getLocalPath();
|
||||
|
@ -382,10 +377,8 @@ public abstract class Operation {
|
|||
}
|
||||
|
||||
protected TransportManager getTransport(MyFile myFile) {
|
||||
// if(Objects.isNull(transport)) {
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
transport=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// }
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
transport=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
return transport;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ public class Remove extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
removeBucket(tm, bucket, myFile);
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
|
@ -30,8 +30,6 @@ public class RenewTTL extends Operation {
|
|||
|
||||
@Override
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException {
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long ttl=-1;
|
||||
try {
|
||||
|
|
|
@ -21,8 +21,6 @@ public class SetMetaInfo extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
tm.setFileProperty(bucket, myFile.getGenericPropertyField(), myFile.getGenericPropertyValue());
|
||||
|
|
|
@ -5,11 +5,9 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
|||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.BucketCoding;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -35,21 +33,6 @@ public abstract class SoftCopy extends Operation {
|
|||
}
|
||||
|
||||
public String initOperation(MyFile file, String remotePath, String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
// if(remotePath != null){
|
||||
// boolean isId=ObjectId.isValid(remotePath);
|
||||
// setResource(file);
|
||||
// if(!isId){
|
||||
//// String[] dirs= remotePath.split(file_separator);
|
||||
// if(logger.isDebugEnabled())
|
||||
// logger.debug("remotePath: "+remotePath);
|
||||
// String buck=null;
|
||||
// buck = new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
// return bucket=buck;
|
||||
// }else{
|
||||
// return bucket=remotePath;
|
||||
// }
|
||||
// }return bucket=null;//else throw new RemoteBackendException("argument cannot be null");
|
||||
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -60,8 +43,6 @@ public abstract class SoftCopy extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
|
@ -84,20 +65,6 @@ public abstract class SoftCopy extends Operation {
|
|||
destinationPath = new BucketCoding().bucketFileCoding(resource.getRemotePath(), rootArea);
|
||||
setResource(resource);
|
||||
return bucket=destinationPath;
|
||||
// if(remotePath != null){
|
||||
// boolean isId=ObjectId.isValid(remotePath);
|
||||
// setResource(resource);
|
||||
// if(!isId){
|
||||
//// String[] dirs= remotePath.split(file_separator);
|
||||
// if(logger.isDebugEnabled())
|
||||
// logger.debug("remotePath: "+remotePath);
|
||||
// String buck=null;
|
||||
// buck = new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
// return bucket=buck;
|
||||
// }else{
|
||||
// return bucket=remotePath;
|
||||
// }
|
||||
// }return bucket=null;//else throw new RemoteBackendException("argument cannot be null");
|
||||
}
|
||||
|
||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||
|
|
|
@ -43,8 +43,6 @@ public abstract class Unlock extends Operation {
|
|||
//inserire parametro per il lock
|
||||
objectId=put(upload, myFile, isChunk(), false, false, true);
|
||||
} catch (Exception e) {
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in unlock operation ", e.getCause());
|
||||
|
|
|
@ -49,8 +49,6 @@ public abstract class Upload extends Operation {
|
|||
try {
|
||||
objectId=put(this, myFile, isChunk(), false, replaceOption, false);
|
||||
} catch (Throwable e) {
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
e.printStackTrace();
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
|
|
|
@ -119,7 +119,7 @@ public class MongoIOManager {
|
|||
logger.error("Problem to open the DB connection for gridfs file ");
|
||||
throw new RemoteBackendException("Problem to open the DB connection: "+ e.getMessage());
|
||||
}
|
||||
logger.info("new mongo connection pool opened");
|
||||
logger.info("mongo connection ready");
|
||||
|
||||
}
|
||||
return db;
|
||||
|
|
Loading…
Reference in New Issue