code refactor. fix conflicts
This commit is contained in:
commit
53e6a45b80
|
@ -2,3 +2,4 @@
|
|||
/.classpath
|
||||
/*.project
|
||||
/.settings
|
||||
/.idea
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -23,7 +23,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.gcube.contentmanagement.blobstorage.resource;
|
|||
*
|
||||
* It means that the client would be upload a file that have an absolute local path defined in pathClient field,
|
||||
* on the remote location identifies by pathServer field of the resource MyFile
|
||||
* @see org.gcube.contentmanagement.blobstorage.resource.RequestObject
|
||||
* @see RequestObject
|
||||
*
|
||||
* @author Roberto Cirillo (ISTI-CNR)
|
||||
*
|
||||
|
|
|
@ -97,7 +97,7 @@ public class DirectoryBucket {
|
|||
logger.debug("CHECK REMOVE: "+bucket);
|
||||
String[] bucketList=null;
|
||||
bucketList=retrieveBucketsName(path, rootArea);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password, null, null);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
|
||||
// TerrastoreClient client=new TerrastoreClient( new OrderedHostManager(Arrays.asList(server)), new HTTPConnectionFactory());
|
||||
for(int i=0;i<bucketList.length;i++){
|
||||
|
@ -130,7 +130,7 @@ public class DirectoryBucket {
|
|||
if(logger.isDebugEnabled())
|
||||
logger.debug("bucketDir Coded: "+bucketDirCoded);
|
||||
bucketList=retrieveBucketsName(bucket, rootArea);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password, region, token);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(),resource.getReadPreference());
|
||||
for(int i=0;i<bucketList.length;i++){
|
||||
if(logger.isDebugEnabled())
|
||||
|
@ -212,7 +212,7 @@ public class DirectoryBucket {
|
|||
* @param tm a client for the cluster
|
||||
*/
|
||||
public String searchInBucket(RequestObject resource, String name, String bucketCoded,
|
||||
TransportManager tm, String rootArea) {
|
||||
TransportManager tm, String rootArea) {
|
||||
Map <String, StorageObject> dirs=null;
|
||||
try{
|
||||
dirs=tm.getValues(resource, bucketCoded, DirectoryEntity.class);
|
||||
|
|
|
@ -8,7 +8,7 @@ import javax.crypto.SecretKey;
|
|||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
import javax.crypto.spec.DESedeKeySpec;
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ public class RemoteResource extends Resource{
|
|||
getMyFile().setOwner(engine.owner);
|
||||
if(engine.getCurrentOperation().equalsIgnoreCase("showdir")){
|
||||
dir = new BucketCoding().bucketDirCoding(dir, engine.getContext());
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword(), engine.getRegion(), engine.getToken());
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword());
|
||||
tm=tmf.getTransport(tm, engine.getBackendType(), engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
|
||||
Map<String, StorageObject> mapDirs=null;
|
||||
try {
|
||||
|
@ -131,7 +131,7 @@ public class RemoteResource extends Resource{
|
|||
if(!Costants.CLIENT_TYPE.equalsIgnoreCase("mongo"))
|
||||
dirBuc.removeDirBucket(getMyFile(), dir, engine.getContext(), engine.getBackendType(), engine.getDbNames());
|
||||
else{
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword(), engine.getRegion(),engine.getToken());
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword());
|
||||
tm=tmf.getTransport(tm, Costants.CLIENT_TYPE, engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
|
||||
dir=new BucketCoding().bucketFileCoding(dir, engine.getContext());
|
||||
try {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RemoteResourceComplexInfo extends Resource{
|
|||
* @throws RemoteBackendException if there are runtime exception from the remote backend
|
||||
*/
|
||||
|
||||
public RequestObject RFile(String path) throws RemoteBackendException{
|
||||
public RequestObject RFile(String path) throws RemoteBackendException{
|
||||
setMyFile(setGenericProperties(engine.getContext(), engine.owner, path, "remote"));
|
||||
getMyFile().setRemotePath(path);
|
||||
getMyFile().setRemoteResource(REMOTE_RESOURCE.PATH);
|
||||
|
|
|
@ -108,7 +108,7 @@ public class ChunkConsumer implements Runnable {
|
|||
return server;
|
||||
}
|
||||
|
||||
private void putInTerrastore(RequestObject myFile) {
|
||||
private void putInTerrastore(RequestObject requestObject) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("putInTerrastore(MyFile) - start");
|
||||
}
|
||||
|
@ -117,8 +117,8 @@ public class ChunkConsumer implements Runnable {
|
|||
start=System.currentTimeMillis();
|
||||
synchronized(ChunkConsumer.class){
|
||||
String [] randomServer=randomizeServer(server);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(randomServer, null, null, null, null);
|
||||
client.set(tmf.getTransport(null, Costants.CLIENT_TYPE, null, null, myFile.getWriteConcern(), myFile.getReadPreference()));
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(randomServer, null, null);
|
||||
client.set(tmf.getTransport(null, Costants.CLIENT_TYPE, null, null, requestObject.getWriteConcern(), requestObject.getReadPreference()));
|
||||
}
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.debug("waiting time for upload: "
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ChunkProducer implements Runnable{
|
|||
final Logger logger=LoggerFactory.getLogger(ChunkProducer.class);
|
||||
|
||||
public ChunkProducer(Monitor monitor, RequestObject resource, long dimensionChunk, int totChunks,
|
||||
int nThreads, String bucket, ChunkConsumer consumer ) throws FileNotFoundException{
|
||||
int nThreads, String bucket, ChunkConsumer consumer ) throws FileNotFoundException{
|
||||
this.resource=resource;
|
||||
this.dimensionChunk=dimensionChunk;
|
||||
this.totChunks=totChunks;
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class Copy extends Operation{
|
|||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -36,8 +36,8 @@ public abstract class Copy extends Operation{
|
|||
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String id=null;
|
||||
try {
|
||||
// id=tm.copy(myFile, sourcePath, destinationPath);
|
||||
|
@ -53,7 +53,7 @@ public abstract class Copy extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// For terrastore, the name of bucket is formed: path_____fileName_____author
|
||||
this.sourcePath=resource.getLocalPath();
|
||||
this.destinationPath=resource.getRemotePath();
|
||||
|
|
|
@ -29,7 +29,7 @@ public abstract class CopyDir extends Operation{
|
|||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -39,8 +39,8 @@ public abstract class CopyDir extends Operation{
|
|||
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm = getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm = getTransport(requestObject);
|
||||
List<String> ids=null;
|
||||
try {
|
||||
// ids=tm.copyDir(myFile, sourcePath, destinationPath);
|
||||
|
@ -58,7 +58,7 @@ public abstract class CopyDir extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// DirectoryBucket dirBuc=new DirectoryBucket(server, user, password, remotePath, author);
|
||||
// For terrastore, the name of bucket is formed: path_____fileName_____author
|
||||
// String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
|
|
|
@ -33,28 +33,28 @@ public abstract class Download extends Operation{
|
|||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.localPath=file.getLocalPath();
|
||||
this.remotePath=remotePath;
|
||||
setResource(file);
|
||||
return getRemoteIdentifier(remotePath, rootArea);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
String id=null;
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
|
||||
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
|
||||
+ " in bucket: " + getBucket());
|
||||
}
|
||||
try {
|
||||
id=get(this, myFile, false);
|
||||
id=get(this, requestObject, false);
|
||||
|
||||
} catch (Throwable e) {
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
tm.close();
|
||||
logger.error("Problem in download from: "+myFile.getRemotePath()+": "+e.getMessage());
|
||||
logger.error("Problem in download from: "+ requestObject.getRemotePath()+": "+e.getMessage());
|
||||
// e.printStackTrace();
|
||||
throw new RemoteBackendException(" Problem in download operation ", e.getCause());
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public abstract class Download extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// DirectoryBucket dirBuc=new DirectoryBucket(server, getUser(), getPassword(), remotePath, author);
|
||||
// For terrastore, the name of bucket is formed: path_____fileName_____author
|
||||
String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
|
|
|
@ -29,17 +29,17 @@ public class DownloadAndLock extends Operation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
|
||||
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
|
||||
+ " in bucket: " + getBucket());
|
||||
}
|
||||
Download download = new DownloadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||
try {
|
||||
//TODO add field for file lock
|
||||
get(download,myFile, true);
|
||||
get(download, requestObject, true);
|
||||
} catch (Exception e) {
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in downloadAndLock operation ", e.getCause());
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class DownloadAndLock extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String RemotePath,
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
this.localPath=file.getLocalPath();
|
||||
this.remotePath=remotePath;
|
||||
return getRemoteIdentifier(remotePath, rootArea);
|
||||
|
@ -57,7 +57,7 @@ public class DownloadAndLock extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ public abstract class DuplicateFile extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String id=null;
|
||||
try {
|
||||
// id = tm.duplicateFile(myFile, bucket);
|
||||
|
@ -45,7 +45,7 @@ public abstract class DuplicateFile extends Operation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath, String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
public String initOperation(RequestObject file, String remotePath, String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
if(remotePath != null){
|
||||
boolean isId=ObjectId.isValid(remotePath);
|
||||
setResource(file);
|
||||
|
@ -65,7 +65,7 @@ public abstract class DuplicateFile extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ public class Exist extends Operation{
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
boolean isPresent=false;
|
||||
try {
|
||||
isPresent = tm.exist(bucket);
|
||||
|
@ -45,7 +45,7 @@ public class Exist extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
|
@ -62,7 +62,7 @@ public class Exist extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with Exist operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ public class ForceClose extends Operation{
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
try {
|
||||
tm.forceClose();
|
||||
} catch (Exception e) {
|
||||
|
@ -31,14 +31,14 @@ public class ForceClose extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ public class GetFolderCount extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType,dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
long dim=0;
|
||||
try {
|
||||
dim = tm.getFolderTotalItems(bucket);
|
||||
|
@ -36,7 +36,7 @@ public class GetFolderCount extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
String buck=null;
|
||||
|
@ -54,7 +54,7 @@ public class GetFolderCount extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ public class GetFolderLastUpdate extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
|
@ -44,7 +44,7 @@ public class GetFolderLastUpdate extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ public class GetFolderSize extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
long dim=0;
|
||||
try {
|
||||
dim = tm.getFolderTotalVolume(bucket);
|
||||
|
@ -36,7 +36,7 @@ public class GetFolderSize extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
|
@ -56,7 +56,7 @@ public class GetFolderSize extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -34,27 +34,27 @@ public class GetHttpUrl extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath, String author,
|
||||
String[] server, String rootArea, boolean replaceOption) {
|
||||
String[] server, String rootArea, boolean replaceOption) {
|
||||
return getRemoteIdentifier(remotePath, rootArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
String resolverHost=myFile.getResolverHOst();
|
||||
public Object doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
String resolverHost= requestObject.getResolverHOst();
|
||||
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);
|
||||
String phrase=myFile.getPassPhrase();
|
||||
String id=getId(requestObject);
|
||||
String phrase= requestObject.getPassPhrase();
|
||||
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
|
||||
urlParam = new Encrypter("DES", phrase).encrypt(id);
|
||||
// String urlEncoded=URLEncoder.encode(urlParam, "UTF-8");
|
||||
|
@ -72,7 +72,7 @@ public class GetHttpUrl extends Operation {
|
|||
e.printStackTrace();
|
||||
}
|
||||
logger.info("URL translated: "+httpUrl);
|
||||
if(myFile.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
|
||||
if(requestObject.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
|
||||
return httpUrl.toString()+Costants.VOLATILE_URL_IDENTIFICATOR;
|
||||
}
|
||||
return httpUrl.toString();
|
||||
|
@ -81,7 +81,7 @@ public class GetHttpUrl extends Operation {
|
|||
@Deprecated
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, getRegion(), getToken());
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
try {
|
||||
id = tm.getId(bucket, forceCreation);
|
||||
|
@ -94,11 +94,11 @@ public class GetHttpUrl extends Operation {
|
|||
return id;
|
||||
}
|
||||
|
||||
private String getId(RequestObject myFile){
|
||||
private String getId(RequestObject requestObject){
|
||||
String id=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
try {
|
||||
id = tm.getId(bucket, myFile.isForceCreation());
|
||||
id = tm.getId(bucket, requestObject.isForceCreation());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
|
||||
|
|
|
@ -30,27 +30,27 @@ public class GetHttpsUrl extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath, String author,
|
||||
String[] server, String rootArea, boolean replaceOption) {
|
||||
String[] server, String rootArea, boolean replaceOption) {
|
||||
return getRemoteIdentifier(remotePath, rootArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
String resolverHost=myFile.getResolverHOst();
|
||||
public Object doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
String resolverHost= requestObject.getResolverHOst();
|
||||
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(requestObject.getAbsoluteRemotePath(), requestObject.isForceCreation(), requestObject.getGcubeMemoryType(), requestObject.getWriteConcern(), requestObject.getReadPreference());
|
||||
// String id=getId(myFile);
|
||||
String phrase=myFile.getPassPhrase();
|
||||
String phrase= requestObject.getPassPhrase();
|
||||
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
|
||||
urlParam = new Encrypter("DES", phrase).encrypt(id);
|
||||
// String urlEncoded=URLEncoder.encode(urlParam, "UTF-8");
|
||||
|
@ -68,17 +68,17 @@ public class GetHttpsUrl extends Operation {
|
|||
e.printStackTrace();
|
||||
}
|
||||
logger.info("URL translated: "+httpsUrl);
|
||||
if(myFile.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
|
||||
if(requestObject.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
|
||||
return httpsUrl.toString()+Costants.VOLATILE_URL_IDENTIFICATOR;
|
||||
}
|
||||
return httpsUrl.toString();
|
||||
}
|
||||
|
||||
private String getId(RequestObject myFile){
|
||||
private String getId(RequestObject requestObject){
|
||||
String id=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
try {
|
||||
id = tm.getId(bucket, myFile.isForceCreation());
|
||||
id = tm.getId(bucket, requestObject.isForceCreation());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
|
||||
|
@ -91,7 +91,7 @@ public class GetHttpsUrl extends Operation {
|
|||
@Deprecated
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, getRegion(), getToken());
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
try {
|
||||
id = tm.getId(bucket, forceCreation);
|
||||
|
|
|
@ -29,20 +29,20 @@ public class GetMetaFile extends Operation{
|
|||
* size.
|
||||
*
|
||||
*/
|
||||
public RequestObject doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public RequestObject doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
long dim=0;
|
||||
String id=null;
|
||||
String mime=null;
|
||||
try {
|
||||
dim = tm.getSize(bucket, myFile);
|
||||
dim = tm.getSize(bucket, requestObject);
|
||||
id=tm.getId(bucket, false);
|
||||
mime=tm.getFileProperty(bucket, "mimetype");
|
||||
myFile.setOwner(tm.getFileProperty(bucket, "owner"));
|
||||
requestObject.setOwner(tm.getFileProperty(bucket, "owner"));
|
||||
if(tm.isValidId(bucket)){
|
||||
myFile.setRemotePath(tm.getFileProperty(bucket, "filename"));
|
||||
myFile.setAbsoluteRemotePath(tm.getFileProperty(bucket, "filename"));
|
||||
myFile.setName(tm.getFileProperty(bucket, "name"));
|
||||
requestObject.setRemotePath(tm.getFileProperty(bucket, "filename"));
|
||||
requestObject.setAbsoluteRemotePath(tm.getFileProperty(bucket, "filename"));
|
||||
requestObject.setName(tm.getFileProperty(bucket, "name"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
|
@ -50,16 +50,16 @@ public class GetMetaFile extends Operation{
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" PATH " + bucket);
|
||||
}
|
||||
myFile.setSize(dim);
|
||||
myFile.setId(id);
|
||||
myFile.setMimeType(mime);
|
||||
requestObject.setSize(dim);
|
||||
requestObject.setId(id);
|
||||
requestObject.setMimeType(mime);
|
||||
|
||||
return myFile;
|
||||
return requestObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
|
@ -76,7 +76,7 @@ public class GetMetaFile extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ public class GetMetaInfo extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String value=null;
|
||||
try {
|
||||
value=tm.getFileProperty(bucket, myFile.getGenericPropertyField());
|
||||
value=tm.getFileProperty(bucket, requestObject.getGenericPropertyField());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetMetaFile operation ", e.getCause()); }
|
||||
|
@ -36,7 +36,7 @@ public class GetMetaInfo extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
|
@ -53,7 +53,7 @@ public class GetMetaInfo extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("method not compatible with getMetaInfo operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ public class GetRemotePath extends Operation{
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType,dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String path=null;
|
||||
try {
|
||||
path = tm.getRemotePath(bucket);
|
||||
|
@ -43,7 +43,7 @@ public class GetRemotePath extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
rootPath=file.getRootPath();
|
||||
logger.trace("rootArea is "+file.getRootPath()+ " absoluteremotepath is "+file.getAbsoluteRemotePath());
|
||||
if(logger.isDebugEnabled())
|
||||
|
@ -59,7 +59,7 @@ public class GetRemotePath extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ public class GetSize extends Operation{
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
long dim=0;
|
||||
try {
|
||||
dim = tm.getSize(bucket, myFile);
|
||||
dim = tm.getSize(bucket, requestObject);
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetSize operation ", e.getCause()); }
|
||||
|
@ -42,7 +42,7 @@ public class GetSize extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
String buck=null;
|
||||
|
@ -58,7 +58,7 @@ public class GetSize extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,16 @@ public class GetTTL extends Operation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
|
||||
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
|
||||
+ " in bucket: " + bucket);
|
||||
}
|
||||
long currentTTL=-1;
|
||||
TransportManager tm=null;
|
||||
try {
|
||||
//aggiungere field per il lock del file
|
||||
tm=getTransport(myFile);
|
||||
tm=getTransport(requestObject);
|
||||
currentTTL=tm.getTTL(bucket);
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
|
@ -46,8 +46,8 @@ public class GetTTL extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
this.localPath=file.getLocalPath();
|
||||
this.remotePath=remotePath;
|
||||
return getRemoteIdentifier(remotePath, rootArea);
|
||||
|
@ -58,7 +58,7 @@ public class GetTTL extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -26,34 +26,34 @@ public class GetUrl extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath, String author,
|
||||
String[] server, String rootArea, boolean replaceOption) {
|
||||
String[] server, String rootArea, boolean replaceOption) {
|
||||
return getRemoteIdentifier(remotePath, rootArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
String resolverHost=myFile.getResolverHOst();
|
||||
public Object doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
String resolverHost= requestObject.getResolverHOst();
|
||||
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);
|
||||
String phrase=myFile.getPassPhrase();
|
||||
String id=getId(requestObject);
|
||||
String phrase= requestObject.getPassPhrase();
|
||||
urlParam = new Encrypter("DES", phrase).encrypt(id);
|
||||
} catch (EncryptionException e) {
|
||||
throw new RemoteBackendException(" Error in getUrl operation problem to encrypt the string", e.getCause());
|
||||
}
|
||||
String url=urlBase+urlParam;
|
||||
logger.info("URL generated: "+url);
|
||||
if(myFile.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
|
||||
if(requestObject.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
|
||||
return url.toString()+Costants.VOLATILE_URL_IDENTIFICATOR;
|
||||
}
|
||||
return url;
|
||||
|
@ -62,7 +62,7 @@ public class GetUrl extends Operation{
|
|||
@Deprecated
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, getRegion(), getToken());
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
try {
|
||||
id = tm.getId(bucket, forceCreation);
|
||||
|
@ -75,11 +75,11 @@ public class GetUrl extends Operation{
|
|||
return id;
|
||||
}
|
||||
|
||||
private String getId(RequestObject myFile){
|
||||
private String getId(RequestObject requestObject){
|
||||
String id=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
try {
|
||||
id = tm.getId(bucket, myFile.isForceCreation());
|
||||
id = tm.getId(bucket, requestObject.isForceCreation());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
|
||||
|
|
|
@ -18,8 +18,8 @@ public class GetUserTotalItems extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String dim=null;
|
||||
logger.info("check user total items for user: "+getOwner()+ " user is "+user);
|
||||
try {
|
||||
|
@ -36,7 +36,7 @@ public class GetUserTotalItems extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
setOwner(author);
|
||||
if((remotePath != null) && (remotePath.length() > 0)){
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
|
@ -62,7 +62,7 @@ public class GetUserTotalItems extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ public class GetUserTotalVolume extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String dim=null;
|
||||
logger.info("check user total volume for user: "+getOwner()+ " user is "+user);
|
||||
try {
|
||||
|
@ -35,7 +35,7 @@ public class GetUserTotalVolume extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
setOwner(author);
|
||||
if(remotePath!= null && remotePath.length()>0){
|
||||
// String[] dirs= remotePath.split(file_separator);
|
||||
|
@ -60,7 +60,7 @@ public class GetUserTotalVolume extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public abstract class Link extends Operation{
|
|||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -35,8 +35,8 @@ public abstract class Link extends Operation{
|
|||
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String id=null;
|
||||
try {
|
||||
id=tm.link(this);
|
||||
|
@ -51,7 +51,7 @@ public abstract class Link extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// For terrastore, the name of bucket is formed: path_____fileName_____author
|
||||
// String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
this.sourcePath=resource.getLocalPath();
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.io.OutputStream;
|
|||
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||
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.gcube.contentmanagement.blobstorage.transport.backend.operation.DownloadOperator;
|
||||
|
@ -33,18 +32,18 @@ public abstract class Lock extends Operation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
|
||||
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
|
||||
+ " in bucket: " + getBucket());
|
||||
}
|
||||
String unlockKey=null;
|
||||
try {
|
||||
//aggiungere field per il lock del file
|
||||
Download download = new DownloadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||
unlockKey=get(download, myFile, true);
|
||||
unlockKey=get(download, requestObject, true);
|
||||
} catch (Exception e) {
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in lock operation ", e.getCause());
|
||||
}
|
||||
|
@ -53,8 +52,8 @@ public abstract class Lock extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String bucketName=null;
|
||||
setResource(file);
|
||||
// create the directory bucket
|
||||
|
@ -72,7 +71,7 @@ public abstract class Lock extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class Monitor {
|
|||
// private static final GCUBELog logger = new GCUBELog(Monitor.class);
|
||||
final Logger logger=LoggerFactory.getLogger(Monitor.class);
|
||||
// request queue
|
||||
private Vector<RequestObject> requestQueue = new Vector<RequestObject>();
|
||||
private Vector<RequestObject> requestQueue = new Vector<RequestObject>();
|
||||
// fetch the first request in the queue
|
||||
public synchronized RequestObject getRequest(){
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
@ -36,12 +36,12 @@ public class Monitor {
|
|||
logger.error("getRequest()", e);
|
||||
}
|
||||
}
|
||||
RequestObject myFile=requestQueue.remove(0);
|
||||
RequestObject requestObject =requestQueue.remove(0);
|
||||
notifyAll();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getRequest() - end");
|
||||
}
|
||||
return myFile;
|
||||
return requestObject;
|
||||
}
|
||||
|
||||
public synchronized RequestObject getRequest(ChunkProducer producer){
|
||||
|
@ -56,12 +56,12 @@ public class Monitor {
|
|||
logger.error("getRequest(ChunkProducer)", e);
|
||||
}
|
||||
}
|
||||
RequestObject myFile=requestQueue.remove(0);
|
||||
RequestObject requestObject =requestQueue.remove(0);
|
||||
notifyAll();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getRequest(ChunkProducer) - end");
|
||||
}
|
||||
return myFile;
|
||||
return requestObject;
|
||||
}
|
||||
|
||||
// Accoda una nuova richiesta
|
||||
|
|
|
@ -26,7 +26,7 @@ public abstract class Move extends Operation{
|
|||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -36,8 +36,8 @@ public abstract class Move extends Operation{
|
|||
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String id=null;
|
||||
try {
|
||||
id=tm.move(this);
|
||||
|
@ -52,7 +52,7 @@ public abstract class Move extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
this.sourcePath=resource.getLocalPath();
|
||||
this.destinationPath=resource.getRemotePath();
|
||||
sourcePath = new BucketCoding().bucketFileCoding(resource.getLocalPath(), rootArea);
|
||||
|
@ -61,7 +61,7 @@ public abstract class Move extends Operation{
|
|||
return bucket=destinationPath;
|
||||
}
|
||||
|
||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||
|
||||
public String getSourcePath() {
|
||||
return sourcePath;
|
||||
|
|
|
@ -27,7 +27,7 @@ public abstract class MoveDir extends Operation{
|
|||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -37,8 +37,8 @@ public abstract class MoveDir extends Operation{
|
|||
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
List<String>ids=null;
|
||||
try {
|
||||
ids=tm.moveDir(this);
|
||||
|
@ -53,7 +53,7 @@ public abstract class MoveDir extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
this.sourcePath=resource.getLocalPath();
|
||||
this.destinationPath=resource.getRemotePath();
|
||||
sourcePath = new BucketCoding().bucketFileCoding(resource.getLocalPath(), rootArea);
|
||||
|
|
|
@ -169,23 +169,23 @@ public abstract class Operation {
|
|||
|
||||
/**
|
||||
* Download operation
|
||||
* @param myFile object that contains the resource coordinates
|
||||
* @param requestObject object that contains the resource coordinates
|
||||
* @throws IOException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public String get(Download download, RequestObject myFile, boolean isLock) throws IOException, InterruptedException, Exception {
|
||||
public String get(Download download, RequestObject requestObject, boolean isLock) throws IOException, InterruptedException, Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("get(String) - start");
|
||||
}
|
||||
String unlocKey=null;
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
long start=System.currentTimeMillis();
|
||||
String path=myFile.getLocalPath();
|
||||
String path= requestObject.getLocalPath();
|
||||
if(!Costants.CLIENT_TYPE.equalsIgnoreCase("mongo")){
|
||||
startPThreadChunk(download, myFile, tm, path);
|
||||
startPThreadChunk(download, requestObject, tm, path);
|
||||
|
||||
}else{
|
||||
unlocKey=tm.downloadManager(download, myFile, bucket, RequestObject.class);
|
||||
unlocKey=tm.downloadManager(download, requestObject, bucket, RequestObject.class);
|
||||
}
|
||||
|
||||
if((path!=null) && (new File(path).length()>0)){
|
||||
|
@ -198,15 +198,20 @@ public abstract class Operation {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param myFile
|
||||
* @param requestObject
|
||||
* @param tm
|
||||
* @param path
|
||||
* @throws FileNotFoundException
|
||||
* @throws InterruptedException
|
||||
* @throws IOException
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
protected void startPThreadChunk(Download download,RequestObject myFile, TransportManager tm,
|
||||
String path) throws FileNotFoundException, InterruptedException,
|
||||
=======
|
||||
protected void startPThreadChunk(Download download, RequestObject requestObject, TransportManager tm,
|
||||
String path) throws FileNotFoundException, InterruptedException,
|
||||
>>>>>>> bbfabd37d9a611db863da6d43f183d710cb9b30c
|
||||
IOException {
|
||||
ExecutorService executor = Executors.newFixedThreadPool (2);
|
||||
int j=0;
|
||||
|
@ -274,11 +279,15 @@ public abstract class Operation {
|
|||
|
||||
/**
|
||||
* Do a operation
|
||||
* @param myFile object that contains the resource coordinates
|
||||
* @param requestObject object that contains the resource coordinates
|
||||
* @return a generic object that contains operation results
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
public abstract Object doIt(RequestObject myFile) throws RemoteBackendException;
|
||||
=======
|
||||
public abstract Object doIt(RequestObject requestObject) throws RemoteBackendException;
|
||||
>>>>>>> bbfabd37d9a611db863da6d43f183d710cb9b30c
|
||||
|
||||
/**
|
||||
* init a operation
|
||||
|
@ -394,7 +403,7 @@ public abstract class Operation {
|
|||
|
||||
protected TransportManager getTransport(RequestObject myFile) {
|
||||
// if(Objects.isNull(transport)) {
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, region, token);
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
transport=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// }
|
||||
return transport;
|
||||
|
|
|
@ -33,12 +33,12 @@ public class OperationManager {
|
|||
|
||||
|
||||
|
||||
public OperationManager(String[] server, String user, String password, String operation, RequestObject myFile, String backendType, String[] dbs, String token){
|
||||
public OperationManager(String[] server, String user, String password, String operation, RequestObject requestObject, String backendType, String[] dbs, String token){
|
||||
this.setServer(server);
|
||||
this.setUser(user);
|
||||
this.setPassword(password);
|
||||
this.setTypeOperation(operation);
|
||||
this.setResource(myFile);
|
||||
this.setResource(requestObject);
|
||||
this.setTypeOperation(operation);
|
||||
this.setDbNames(dbs);
|
||||
this.backendType=backendType;
|
||||
|
|
|
@ -23,9 +23,9 @@ public class Remove extends Operation{
|
|||
super(server,user,pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
removeBucket(tm, bucket, myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
removeBucket(tm, bucket, requestObject);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" REMOVE " + bucket);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class Remove extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String[] dirs= remotePath.split(Costants.FILE_SEPARATOR);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
|
@ -75,7 +75,7 @@ public class Remove extends Operation{
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with remove operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ public class RenewTTL extends Operation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
long ttl=-1;
|
||||
try {
|
||||
myFile.setRemotePath(bucket);
|
||||
ttl = tm.renewTTL(myFile);
|
||||
requestObject.setRemotePath(bucket);
|
||||
ttl = tm.renewTTL(requestObject);
|
||||
} catch (Throwable e) {
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in renew TTL operation ", e.getCause());
|
||||
|
@ -43,8 +43,8 @@ public class RenewTTL extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
this.localPath=file.getLocalPath();
|
||||
this.remotePath=remotePath;
|
||||
String bucketName = new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
|
@ -54,7 +54,7 @@ public class RenewTTL extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ public class SetMetaInfo extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
try {
|
||||
tm.setFileProperty(bucket, myFile.getGenericPropertyField(), myFile.getGenericPropertyValue());
|
||||
tm.setFileProperty(bucket, requestObject.getGenericPropertyField(), requestObject.getGenericPropertyValue());
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
e.printStackTrace();
|
||||
|
@ -36,7 +36,7 @@ public class SetMetaInfo extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("remotePath: "+remotePath);
|
||||
String buck=null;
|
||||
|
@ -52,7 +52,7 @@ public class SetMetaInfo extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public abstract class SoftCopy extends Operation {
|
|||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
public String initOperation(RequestObject file, String remotePath, String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
public String initOperation(RequestObject file, String remotePath, String author, String[] server, String rootArea, boolean replaceOption) {
|
||||
this.sourcePath=file.getLocalPath();
|
||||
this.destinationPath=remotePath;
|
||||
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
|
||||
|
@ -42,8 +42,8 @@ public abstract class SoftCopy extends Operation {
|
|||
|
||||
}
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(myFile);
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
String id=null;
|
||||
try {
|
||||
id=tm.softCopy(this);
|
||||
|
|
|
@ -31,18 +31,18 @@ public abstract class Unlock extends Operation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException {
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" UPLOAD " + myFile.getLocalPath()
|
||||
+ " author: " + myFile.getOwner());
|
||||
logger.debug(" UPLOAD " + requestObject.getLocalPath()
|
||||
+ " author: " + requestObject.getOwner());
|
||||
}
|
||||
String objectId=null;
|
||||
try {
|
||||
Upload upload= new UploadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||
//inserire parametro per il lock
|
||||
objectId=put(upload, myFile, isChunk(), false, false, true);
|
||||
objectId=put(upload, requestObject, isChunk(), false, false, true);
|
||||
} catch (Exception e) {
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in unlock operation ", e.getCause());
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ public abstract class Unlock extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
String bucketName=null;
|
||||
// create the directory bucket
|
||||
if((remotePath.length()<23) || (remotePath.contains(Costants.FILE_SEPARATOR))){
|
||||
|
@ -69,7 +69,7 @@ public abstract class Unlock extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -39,19 +39,19 @@ public abstract class Upload extends Operation {
|
|||
|
||||
|
||||
|
||||
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" UPLOAD " + myFile.getLocalPath()
|
||||
+ " author: " + myFile.getOwner());
|
||||
logger.debug(" UPLOAD " + requestObject.getLocalPath()
|
||||
+ " author: " + requestObject.getOwner());
|
||||
}
|
||||
String objectId=null;
|
||||
try {
|
||||
objectId=put(this, myFile, isChunk(), false, replaceOption, false);
|
||||
objectId=put(this, requestObject, isChunk(), false, replaceOption, false);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
TransportManager tm=getTransport(myFile);
|
||||
TransportManager tm=getTransport(requestObject);
|
||||
tm.close();
|
||||
logger.error("Problem in upload from: "+myFile.getLocalPath()+": "+e.getMessage());
|
||||
logger.error("Problem in upload from: "+ requestObject.getLocalPath()+": "+e.getMessage());
|
||||
throw new RemoteBackendException(" Error in upload operation ", e.getCause());
|
||||
}
|
||||
return objectId;
|
||||
|
@ -79,7 +79,7 @@ public abstract class Upload extends Operation {
|
|||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
String author, String[] server, String rootArea) {
|
||||
// the name of bucket is formed: path_____fileName_____author
|
||||
String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
setResource(resource);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||
|
||||
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||
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.RemoteBackendException;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.UploadOperator;
|
||||
/**
|
||||
* @deprecated
|
||||
* @author Roberto Cirillo (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class UploadAndUnlock extends Operation {
|
||||
|
||||
// private String keyUnlock;
|
||||
|
||||
public UploadAndUnlock(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||
// TODO Auto-generated constructor stub
|
||||
super(server,user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doIt(RequestObject requestObject) throws RemoteBackendException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" UPLOAD " + requestObject.getLocalPath()
|
||||
+ " author: " + requestObject.getOwner());
|
||||
}
|
||||
Upload upload= new UploadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||
String objectId=null;
|
||||
try {
|
||||
//inserire parametro per il lock
|
||||
objectId=put(upload, requestObject, isChunk(), false, false, true);
|
||||
} catch (Exception e) {
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(transport, backendType, requestObject.getGcubeMemoryType(), dbNames, requestObject.getWriteConcern(), requestObject.getReadPreference());
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in uploadAndUnlock operation ", e);
|
||||
}
|
||||
return objectId;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject file, String remotePath,
|
||||
String author, String[] server, String rootArea,
|
||||
boolean replaceOption) {
|
||||
// set replace option
|
||||
// this.replaceOption=replaceOption;
|
||||
// the name of bucket is formed: path_____fileName_____author
|
||||
String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
||||
return bucket=bucketName;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initOperation(RequestObject resource, String RemotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -43,19 +43,19 @@ public abstract class TransportManager {
|
|||
|
||||
/**
|
||||
* Start the download operation. It contains logic to determine the correct operation based on the input parameters
|
||||
* @param myFile object that contains the resource coordinates
|
||||
* @param requestObject object that contains the resource coordinates
|
||||
* @param key remote path or objectId
|
||||
* @param type class type of myFile object
|
||||
* @return the key of remote resource
|
||||
* @throws IOException if there are IO problems
|
||||
*/
|
||||
public String downloadManager(Download download, RequestObject myFile, String key, Class <? extends Object> type) throws Exception{
|
||||
public String downloadManager(Download download, RequestObject requestObject, String key, Class <? extends Object> type) throws Exception{
|
||||
String key4lock=null;
|
||||
if(myFile.isLock()){
|
||||
download.setResource(myFile);
|
||||
if(requestObject.isLock()){
|
||||
download.setResource(requestObject);
|
||||
get(download);
|
||||
Lock lock= new LockOperator(download.getServer(), download.getUser(), download.getPassword(), download.getBucket(), download.getMonitor(), download.isChunk(), download.getBackendType(), download.getDbNames());
|
||||
lock.setResource(myFile);
|
||||
lock.setResource(requestObject);
|
||||
key4lock=lock(lock);
|
||||
return key4lock;
|
||||
}else{
|
||||
|
@ -145,22 +145,22 @@ public abstract class TransportManager {
|
|||
/**
|
||||
* delete a remote directory
|
||||
* @param remoteDir remote Directory path
|
||||
* @param myFile
|
||||
* @param requestObject
|
||||
* @throws IllegalStateException
|
||||
* @throws UnknownHostException
|
||||
*
|
||||
*/
|
||||
public abstract void removeDir(String remoteDir, RequestObject myFile) throws UnknownHostException;
|
||||
public abstract void removeDir(String remoteDir, RequestObject requestObject) throws UnknownHostException;
|
||||
|
||||
|
||||
/**
|
||||
* get the size of the remote file
|
||||
* @param bucket identifies the remote file path
|
||||
* @param myFile the file wrapper
|
||||
* @param requestObject the file wrapper
|
||||
* @return the size of the remote file
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public abstract long getSize(String bucket, RequestObject myFile);
|
||||
public abstract long getSize(String bucket, RequestObject requestObject);
|
||||
|
||||
/**
|
||||
* lock a remote file
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TransportManagerFactory {
|
|||
private String region;
|
||||
TransportManager transport;
|
||||
|
||||
public TransportManagerFactory(String server[], String user, String password, String region, String token){
|
||||
public TransportManagerFactory(String[] server, String user, String password){
|
||||
this.server=server;
|
||||
this.user=user;
|
||||
this.password=password;
|
||||
|
|
|
@ -216,7 +216,11 @@ public class MongoIOManager {
|
|||
* @param isLock indicates if the file must be locked
|
||||
* @throws IOException
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
private void download( RequestObject resource, GridFSDBFile f, boolean isLock) throws IOException {
|
||||
=======
|
||||
private void download(RequestObject resource, GridFSDBFile f, boolean isLock) throws IOException {
|
||||
>>>>>>> bbfabd37d9a611db863da6d43f183d710cb9b30c
|
||||
OperationDefinition op=resource.getOperationDefinition();
|
||||
logger.info("MongoClient download method: "+op.toString());
|
||||
// if contains the field link it means that is a link hence I follow ne or more links
|
||||
|
@ -536,7 +540,11 @@ public class MongoIOManager {
|
|||
|
||||
|
||||
public void setGenericProperties(RequestObject resource, String destination,
|
||||
<<<<<<< HEAD
|
||||
String dir, GridFSInputFile destinationFile, String name) {
|
||||
=======
|
||||
String dir, GridFSInputFile destinationFile, String name) {
|
||||
>>>>>>> bbfabd37d9a611db863da6d43f183d710cb9b30c
|
||||
updateCommonFields(destinationFile, resource, null);
|
||||
destinationFile.put("filename", destination);
|
||||
destinationFile.put("type", "file");
|
||||
|
@ -548,7 +556,11 @@ public class MongoIOManager {
|
|||
}
|
||||
|
||||
public DBObject setGenericMoveProperties(RequestObject resource, String filename, String dir,
|
||||
<<<<<<< HEAD
|
||||
String name, DBObject sourcePathMetaCollection) {
|
||||
=======
|
||||
String name, DBObject sourcePathMetaCollection) {
|
||||
>>>>>>> bbfabd37d9a611db863da6d43f183d710cb9b30c
|
||||
sourcePathMetaCollection.put("filename", filename);
|
||||
sourcePathMetaCollection.put("type", "file");
|
||||
sourcePathMetaCollection.put("name", name);
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
|||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition;
|
||||
import org.gcube.contentmanagement.blobstorage.service.operation.*;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||
|
|
|
@ -53,7 +53,11 @@ public class MoveOperator extends Move {
|
|||
*/
|
||||
@Override
|
||||
// public String execute(MongoIO mongoPrimaryInstance, MemoryType memoryType) throws UnknownHostException {
|
||||
<<<<<<< HEAD
|
||||
public String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
||||
=======
|
||||
public String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
||||
>>>>>>> bbfabd37d9a611db863da6d43f183d710cb9b30c
|
||||
String source=sourcePath;
|
||||
String destination=destinationPath;
|
||||
resource.setLocalPath(sourcePath);
|
||||
|
|
Loading…
Reference in New Issue