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