update to gcube-bom 3.0.0-SNAPSHOT. Refactoring of RequestObject class
This commit is contained in:
parent
7837184e4b
commit
bbfabd37d9
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.MyFile
|
* @see RequestObject
|
||||||
*
|
*
|
||||||
* @author Roberto Cirillo (ISTI-CNR)
|
* @author Roberto Cirillo (ISTI-CNR)
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Roberto Cirillo (ISTI - CNR)
|
* @author Roberto Cirillo (ISTI - CNR)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MyFile {
|
public class RequestObject {
|
||||||
|
|
||||||
// file name
|
// file name
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -95,10 +95,10 @@ public class MyFile {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final Logger logger = LoggerFactory.getLogger(MyFile.class);
|
final Logger logger = LoggerFactory.getLogger(RequestObject.class);
|
||||||
|
|
||||||
|
|
||||||
public MyFile(boolean lock){
|
public RequestObject(boolean lock){
|
||||||
setLock(lock);
|
setLock(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class MyFile {
|
||||||
* @param name name of the file
|
* @param name name of the file
|
||||||
* @param pathClient local path of the file
|
* @param pathClient local path of the file
|
||||||
*/
|
*/
|
||||||
public MyFile(String author, String name, String pathClient, MemoryType memoryType){
|
public RequestObject(String author, String name, String pathClient, MemoryType memoryType){
|
||||||
this.setOwner(author);
|
this.setOwner(author);
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
this.setLocalPath(pathClient);
|
this.setLocalPath(pathClient);
|
||||||
|
@ -123,7 +123,7 @@ public class MyFile {
|
||||||
* @param pathServer remote path of the file
|
* @param pathServer remote path of the file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public MyFile(String author, String name, String pathClient, String pathServer, MemoryType memoryType){
|
public RequestObject(String author, String name, String pathClient, String pathServer, MemoryType memoryType){
|
||||||
this.setOwner(author);
|
this.setOwner(author);
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
this.setLocalPath(pathClient);
|
this.setLocalPath(pathClient);
|
||||||
|
@ -131,7 +131,7 @@ public class MyFile {
|
||||||
setGcubeMemoryType(memoryType);
|
setGcubeMemoryType(memoryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile(MemoryType memoryType) {
|
public RequestObject(MemoryType memoryType) {
|
||||||
setGcubeMemoryType(memoryType);
|
setGcubeMemoryType(memoryType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class MyFile {
|
||||||
* build a new object with only the name setted
|
* build a new object with only the name setted
|
||||||
* @param name file name
|
* @param name file name
|
||||||
*/
|
*/
|
||||||
public MyFile(String name, MemoryType memoryType){
|
public RequestObject(String name, MemoryType memoryType){
|
||||||
setName(name);
|
setName(name);
|
||||||
setGcubeMemoryType(memoryType);
|
setGcubeMemoryType(memoryType);
|
||||||
}
|
}
|
||||||
|
@ -245,8 +245,8 @@ public class MyFile {
|
||||||
* returns a copy of the current resource
|
* returns a copy of the current resource
|
||||||
* @return the file copy
|
* @return the file copy
|
||||||
*/
|
*/
|
||||||
public MyFile copyProperties(){
|
public RequestObject copyProperties(){
|
||||||
MyFile dest=new MyFile(getGcubeMemoryType());
|
RequestObject dest=new RequestObject(getGcubeMemoryType());
|
||||||
dest.setOwner(getOwner());
|
dest.setOwner(getOwner());
|
||||||
dest.setLocalDir(this.getLocalDir());
|
dest.setLocalDir(this.getLocalDir());
|
||||||
dest.setRemoteDir(this.getRemoteDir());
|
dest.setRemoteDir(this.getRemoteDir());
|
|
@ -5,7 +5,7 @@ import java.net.UnknownHostException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||||
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.TransportManagerFactory;
|
||||||
|
@ -92,12 +92,12 @@ public class DirectoryBucket {
|
||||||
* @param bucket remote file to remove
|
* @param bucket remote file to remove
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void removeKeysOnDirBucket(MyFile resource, String bucket, String rootArea, String backendType, String[] dbNames){
|
public void removeKeysOnDirBucket(RequestObject resource, String bucket, String rootArea, String backendType, String[] dbNames){
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
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++){
|
||||||
|
@ -121,7 +121,7 @@ public class DirectoryBucket {
|
||||||
* remove a remote directory and all the files that the remote directory contains
|
* remove a remote directory and all the files that the remote directory contains
|
||||||
* @param bucket
|
* @param bucket
|
||||||
*/
|
*/
|
||||||
public String removeDirBucket(MyFile resource, String bucket, String rootArea, String backendType, String[] dbNames){
|
public String removeDirBucket(RequestObject resource, String bucket, String rootArea, String backendType, String[] dbNames){
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
logger.debug("CHECK REMOVE: "+bucket);
|
logger.debug("CHECK REMOVE: "+bucket);
|
||||||
String[] bucketList=null;
|
String[] bucketList=null;
|
||||||
|
@ -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())
|
||||||
|
@ -211,8 +211,8 @@ public class DirectoryBucket {
|
||||||
* @param bucketCoded bucketName coded
|
* @param bucketCoded bucketName coded
|
||||||
* @param tm a client for the cluster
|
* @param tm a client for the cluster
|
||||||
*/
|
*/
|
||||||
public String searchInBucket(MyFile 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);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.directoryOperation;
|
package org.gcube.contentmanagement.blobstorage.service.directoryOperation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,7 @@ public class DirectoryEntity {
|
||||||
setAuthor(author);
|
setAuthor(author);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectoryEntity(String dir, String author, MyFile file){
|
public DirectoryEntity(String dir, String author, RequestObject file){
|
||||||
setDirectory(dir);
|
setDirectory(dir);
|
||||||
setAuthor(author);
|
setAuthor(author);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
||||||
/**
|
/**
|
||||||
* This class is used from methods that can have both a RemoteResource or a LocalResource
|
* This class is used from methods that can have both a RemoteResource or a LocalResource
|
||||||
|
@ -10,7 +10,7 @@ import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCA
|
||||||
*/
|
*/
|
||||||
public class AmbiguousResource extends RemoteResource {
|
public class AmbiguousResource extends RemoteResource {
|
||||||
|
|
||||||
public AmbiguousResource(MyFile file, ServiceEngine engine) {
|
public AmbiguousResource(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMO
|
||||||
public class LocalResource extends Resource{
|
public class LocalResource extends Resource{
|
||||||
|
|
||||||
|
|
||||||
public LocalResource(MyFile file, ServiceEngine engine) {
|
public LocalResource(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class LocalResource extends Resource{
|
||||||
if(getMyFile() != null){
|
if(getMyFile() != null){
|
||||||
getMyFile().setInputStream(is);
|
getMyFile().setInputStream(is);
|
||||||
}else{
|
}else{
|
||||||
setMyFile(new MyFile(engine.getGcubeMemoryType()));
|
setMyFile(new RequestObject(engine.getGcubeMemoryType()));
|
||||||
getMyFile().setInputStream(is);
|
getMyFile().setInputStream(is);
|
||||||
}
|
}
|
||||||
getMyFile().setLocalResource(LOCAL_RESOURCE.INPUT_STREAM);
|
getMyFile().setLocalResource(LOCAL_RESOURCE.INPUT_STREAM);
|
||||||
|
@ -62,7 +62,7 @@ public class LocalResource extends Resource{
|
||||||
if(getMyFile() != null){
|
if(getMyFile() != null){
|
||||||
getMyFile().setOutputStream(os);
|
getMyFile().setOutputStream(os);
|
||||||
}else{
|
}else{
|
||||||
setMyFile(new MyFile(engine.getGcubeMemoryType()));
|
setMyFile(new RequestObject(engine.getGcubeMemoryType()));
|
||||||
getMyFile().setOutputStream(os);
|
getMyFile().setOutputStream(os);
|
||||||
}
|
}
|
||||||
getMyFile().setLocalResource(LOCAL_RESOURCE.OUTPUT_STREAM);
|
getMyFile().setLocalResource(LOCAL_RESOURCE.OUTPUT_STREAM);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.net.UnknownHostException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.service.directoryOperation.DirectoryBucket;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryEntity;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryEntity;
|
||||||
|
@ -28,7 +28,7 @@ public class RemoteResource extends Resource{
|
||||||
|
|
||||||
TransportManager tm;
|
TransportManager tm;
|
||||||
|
|
||||||
public RemoteResource(MyFile file, ServiceEngine engine) {
|
public RemoteResource(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
logger.info("file gCube parameter costructor: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
|
logger.info("file gCube parameter costructor: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class RemoteResourceBoolean extends Resource{
|
||||||
* @param file
|
* @param file
|
||||||
* @param engine
|
* @param engine
|
||||||
*/
|
*/
|
||||||
public RemoteResourceBoolean(MyFile file, ServiceEngine engine) {
|
public RemoteResourceBoolean(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
logger.info("file gCube parameter costructor: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
|
logger.info("file gCube parameter costructor: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
|
||||||
public class RemoteResourceComplexInfo extends Resource{
|
public class RemoteResourceComplexInfo extends Resource{
|
||||||
|
|
||||||
|
|
||||||
public RemoteResourceComplexInfo(MyFile file, ServiceEngine engine) {
|
public RemoteResourceComplexInfo(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 MyFile 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);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
|
||||||
*/
|
*/
|
||||||
public class RemoteResourceDestination extends Resource{
|
public class RemoteResourceDestination extends Resource{
|
||||||
|
|
||||||
public RemoteResourceDestination(MyFile file, ServiceEngine engine) {
|
public RemoteResourceDestination(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RemoteResourceFolderInfo extends Resource {
|
||||||
private String gcubeAccessType;
|
private String gcubeAccessType;
|
||||||
private String gcubeMemoryType;
|
private String gcubeMemoryType;
|
||||||
|
|
||||||
public RemoteResourceFolderInfo(MyFile file, ServiceEngine engine) {
|
public RemoteResourceFolderInfo(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
|
||||||
public class RemoteResourceInfo extends Resource{
|
public class RemoteResourceInfo extends Resource{
|
||||||
|
|
||||||
|
|
||||||
public RemoteResourceInfo(MyFile file, ServiceEngine engine) {
|
public RemoteResourceInfo(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCA
|
||||||
*/
|
*/
|
||||||
public class RemoteResourceSource extends Resource {
|
public class RemoteResourceSource extends Resource {
|
||||||
|
|
||||||
public RemoteResourceSource(MyFile file, ServiceEngine engine) {
|
public RemoteResourceSource(RequestObject file, ServiceEngine engine) {
|
||||||
super(file, engine);
|
super(file, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.impl;
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||||
|
@ -19,11 +19,11 @@ public class Resource {
|
||||||
|
|
||||||
final Logger logger = LoggerFactory.getLogger(ServiceEngine.class);
|
final Logger logger = LoggerFactory.getLogger(ServiceEngine.class);
|
||||||
protected static final String BACKEND_STRING_SEPARATOR="%";
|
protected static final String BACKEND_STRING_SEPARATOR="%";
|
||||||
protected MyFile file;
|
protected RequestObject file;
|
||||||
protected ServiceEngine engine;
|
protected ServiceEngine engine;
|
||||||
|
|
||||||
|
|
||||||
public Resource(MyFile file, ServiceEngine engine){
|
public Resource(RequestObject file, ServiceEngine engine){
|
||||||
setMyFile(file);
|
setMyFile(file);
|
||||||
setEngine(engine);
|
setEngine(engine);
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,11 @@ public class Resource {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MyFile getMyFile(){
|
protected RequestObject getMyFile(){
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setMyFile(MyFile f){
|
protected void setMyFile(RequestObject f){
|
||||||
if (f!=null)
|
if (f!=null)
|
||||||
file=f;
|
file=f;
|
||||||
else
|
else
|
||||||
|
@ -56,11 +56,11 @@ public class Resource {
|
||||||
* @param type remote or local
|
* @param type remote or local
|
||||||
* @return the current resource
|
* @return the current resource
|
||||||
*/
|
*/
|
||||||
protected MyFile setGenericProperties(String context, String owner, String path, String type) {
|
protected RequestObject setGenericProperties(String context, String owner, String path, String type) {
|
||||||
if((path != null) && (path.length()>0)){
|
if((path != null) && (path.length()>0)){
|
||||||
if(ObjectId.isValid(path)){
|
if(ObjectId.isValid(path)){
|
||||||
if(file==null)
|
if(file==null)
|
||||||
file= new MyFile(path, engine.getGcubeMemoryType());
|
file= new RequestObject(path, engine.getGcubeMemoryType());
|
||||||
String id = file.getId();
|
String id = file.getId();
|
||||||
if((id != null) && (!id.isEmpty()))
|
if((id != null) && (!id.isEmpty()))
|
||||||
file.setId2(path);
|
file.setId2(path);
|
||||||
|
@ -75,7 +75,7 @@ public class Resource {
|
||||||
logger.debug("path(String) - name: " + name);
|
logger.debug("path(String) - name: " + name);
|
||||||
}
|
}
|
||||||
if(file == null){
|
if(file == null){
|
||||||
file= new MyFile(name, engine.getGcubeMemoryType());
|
file= new RequestObject(name, engine.getGcubeMemoryType());
|
||||||
}else{
|
}else{
|
||||||
file.setName(name);
|
file.setName(name);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public class Resource {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object getRemoteObject(MyFile file, String[] backend, String[] vltBackend)throws RemoteBackendException {
|
protected Object getRemoteObject(RequestObject file, String[] backend, String[] vltBackend)throws RemoteBackendException {
|
||||||
Object obj=null;
|
Object obj=null;
|
||||||
try{
|
try{
|
||||||
obj=retrieveRemoteObject(file, backend);
|
obj=retrieveRemoteObject(file, backend);
|
||||||
|
@ -122,7 +122,7 @@ public class Resource {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object retrieveRemoteObject(MyFile file, String[] backend) throws RemoteBackendException {
|
protected Object retrieveRemoteObject(RequestObject file, String[] backend) throws RemoteBackendException {
|
||||||
Object obj=null;
|
Object obj=null;
|
||||||
if(((file.getInputStream() != null) || (file.getOutputStream()!=null)) || ((file.getLocalPath() != null) || (file.getRemotePath() != null)))
|
if(((file.getInputStream() != null) || (file.getOutputStream()!=null)) || ((file.getLocalPath() != null) || (file.getRemotePath() != null)))
|
||||||
obj=engine.service.startOperation(file,file.getRemotePath(), file.getOwner(), backend, Costants.DEFAULT_CHUNK_OPTION, file.getRootPath(), file.isReplace(), engine.getRegion(), engine.getToken());
|
obj=engine.service.startOperation(file,file.getRemotePath(), file.getOwner(), backend, Costants.DEFAULT_CHUNK_OPTION, file.getRootPath(), file.isReplace(), engine.getRegion(), engine.getToken());
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.AccessType;
|
import org.gcube.contentmanagement.blobstorage.resource.AccessType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||||
|
@ -43,7 +43,7 @@ public class ServiceEngine implements IClient {
|
||||||
public String[] primaryBackend;
|
public String[] primaryBackend;
|
||||||
public String[] volatileBackend;
|
public String[] volatileBackend;
|
||||||
protected OperationManager service;
|
protected OperationManager service;
|
||||||
protected MyFile file;
|
protected RequestObject file;
|
||||||
protected String bucket;
|
protected String bucket;
|
||||||
protected String bucketID;
|
protected String bucketID;
|
||||||
protected String author;
|
protected String author;
|
||||||
|
@ -412,7 +412,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource remove(String backendType){
|
public RemoteResource remove(String backendType){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(getGcubeMemoryType());
|
file=new RequestObject(getGcubeMemoryType());
|
||||||
file.setGcubeAccessType(this.getGcubeAccessType());
|
file.setGcubeAccessType(this.getGcubeAccessType());
|
||||||
file.setGcubeScope(this.getGcubeScope());
|
file.setGcubeScope(this.getGcubeScope());
|
||||||
file.setOwnerGcube(this.getOwnerGcube());
|
file.setOwnerGcube(this.getOwnerGcube());
|
||||||
|
@ -426,11 +426,11 @@ public class ServiceEngine implements IClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MyFile getMyFile() {
|
public RequestObject getMyFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMyFile(MyFile myFile) {
|
public void setMyFile(RequestObject myFile) {
|
||||||
this.file = myFile;
|
this.file = myFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource showDir(String backendType){
|
public RemoteResource showDir(String backendType){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGcubeAccessType(this.getGcubeAccessType());
|
file.setGcubeAccessType(this.getGcubeAccessType());
|
||||||
file.setGcubeScope(this.getGcubeScope());
|
file.setGcubeScope(this.getGcubeScope());
|
||||||
file.setOwnerGcube(this.getOwnerGcube());
|
file.setOwnerGcube(this.getOwnerGcube());
|
||||||
|
@ -495,7 +495,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource removeDir(String backendType){
|
public RemoteResource removeDir(String backendType){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGcubeAccessType(this.getGcubeAccessType());
|
file.setGcubeAccessType(this.getGcubeAccessType());
|
||||||
file.setGcubeScope(this.getGcubeScope());
|
file.setGcubeScope(this.getGcubeScope());
|
||||||
file.setOwnerGcube(this.getOwnerGcube());
|
file.setOwnerGcube(this.getOwnerGcube());
|
||||||
|
@ -527,7 +527,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource getUrl(String backendType, boolean forceCreation){
|
public RemoteResource getUrl(String backendType, boolean forceCreation){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGcubeAccessType(this.getGcubeAccessType());
|
file.setGcubeAccessType(this.getGcubeAccessType());
|
||||||
file.setGcubeScope(this.getGcubeScope());
|
file.setGcubeScope(this.getGcubeScope());
|
||||||
file.setOwnerGcube(this.getOwnerGcube());
|
file.setOwnerGcube(this.getOwnerGcube());
|
||||||
|
@ -562,7 +562,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource getHttpUrl(String backendType, boolean forceCreation){
|
public RemoteResource getHttpUrl(String backendType, boolean forceCreation){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGcubeAccessType(this.getGcubeAccessType());
|
file.setGcubeAccessType(this.getGcubeAccessType());
|
||||||
file.setGcubeScope(this.getGcubeScope());
|
file.setGcubeScope(this.getGcubeScope());
|
||||||
file.setOwnerGcube(this.getOwnerGcube());
|
file.setOwnerGcube(this.getOwnerGcube());
|
||||||
|
@ -599,7 +599,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource getHttpsUrl(String backendType, boolean forceCreation){
|
public RemoteResource getHttpsUrl(String backendType, boolean forceCreation){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGcubeAccessType(this.getGcubeAccessType());
|
file.setGcubeAccessType(this.getGcubeAccessType());
|
||||||
file.setGcubeScope(this.getGcubeScope());
|
file.setGcubeScope(this.getGcubeScope());
|
||||||
file.setOwnerGcube(this.getOwnerGcube());
|
file.setOwnerGcube(this.getOwnerGcube());
|
||||||
|
@ -672,7 +672,7 @@ public class ServiceEngine implements IClient {
|
||||||
|
|
||||||
public AmbiguousResource lock(String backendType) {
|
public AmbiguousResource lock(String backendType) {
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file = new MyFile(true);
|
file = new RequestObject(true);
|
||||||
setCurrentOperation("lock");
|
setCurrentOperation("lock");
|
||||||
this.service=new OperationManager(primaryBackend, user, password, getCurrentOperation(), file, backendType, getDbNames(), getToken());
|
this.service=new OperationManager(primaryBackend, user, password, getCurrentOperation(), file, backendType, getDbNames(), getToken());
|
||||||
file=setOperationInfo(file, OPERATION.LOCK);
|
file=setOperationInfo(file, OPERATION.LOCK);
|
||||||
|
@ -688,7 +688,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public AmbiguousResource unlock(String key, String backendType) {
|
public AmbiguousResource unlock(String key, String backendType) {
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setLockedKey(key);
|
file.setLockedKey(key);
|
||||||
// put(true);
|
// put(true);
|
||||||
setCurrentOperation("unlock");
|
setCurrentOperation("unlock");
|
||||||
|
@ -706,7 +706,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResourceInfo getTTL(String backendType) {
|
public RemoteResourceInfo getTTL(String backendType) {
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
// put(true);
|
// put(true);
|
||||||
setCurrentOperation("getTTL");
|
setCurrentOperation("getTTL");
|
||||||
file=setOperationInfo(file, OPERATION.GET_TTL);
|
file=setOperationInfo(file, OPERATION.GET_TTL);
|
||||||
|
@ -724,7 +724,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource getMetaInfo(String field, String backendType) {
|
public RemoteResource getMetaInfo(String field, String backendType) {
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGenericPropertyField(field);
|
file.setGenericPropertyField(field);
|
||||||
setCurrentOperation("getMetaInfo");
|
setCurrentOperation("getMetaInfo");
|
||||||
file=setOperationInfo(file, OPERATION.GET_META_INFO);
|
file=setOperationInfo(file, OPERATION.GET_META_INFO);
|
||||||
|
@ -740,7 +740,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResource setMetaInfo(String field, String value, String backendType) {
|
public RemoteResource setMetaInfo(String field, String value, String backendType) {
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setGenericPropertyField(field);
|
file.setGenericPropertyField(field);
|
||||||
file.setGenericPropertyValue(value);
|
file.setGenericPropertyValue(value);
|
||||||
setCurrentOperation("setMetaInfo");
|
setCurrentOperation("setMetaInfo");
|
||||||
|
@ -757,7 +757,7 @@ public class ServiceEngine implements IClient {
|
||||||
@Override
|
@Override
|
||||||
public RemoteResourceInfo renewTTL(String key, String backendType) {
|
public RemoteResourceInfo renewTTL(String key, String backendType) {
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setLockedKey(key);
|
file.setLockedKey(key);
|
||||||
// put(true);
|
// put(true);
|
||||||
setCurrentOperation("renewTTL");
|
setCurrentOperation("renewTTL");
|
||||||
|
@ -999,9 +999,9 @@ public class ServiceEngine implements IClient {
|
||||||
// this.gcubeMemoryType = gcubeMemoryType;
|
// this.gcubeMemoryType = gcubeMemoryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MyFile setOperationInfo(MyFile file, OPERATION op) {
|
private RequestObject setOperationInfo(RequestObject file, OPERATION op) {
|
||||||
if(file==null)
|
if(file==null)
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setOperation(op);
|
file.setOperation(op);
|
||||||
if(getWriteConcern() != null)
|
if(getWriteConcern() != null)
|
||||||
file.setWriteConcern(getWriteConcern());
|
file.setWriteConcern(getWriteConcern());
|
||||||
|
@ -1014,9 +1014,9 @@ public class ServiceEngine implements IClient {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MyFile setMimeType(MyFile file, String mime) {
|
private RequestObject setMimeType(RequestObject file, String mime) {
|
||||||
if(file==null)
|
if(file==null)
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
file.setMimeType(mime);
|
file.setMimeType(mime);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -1095,7 +1095,7 @@ public class ServiceEngine implements IClient {
|
||||||
|
|
||||||
public RemoteResource getRemotePath(){
|
public RemoteResource getRemotePath(){
|
||||||
backendType=setBackendType(backendType);
|
backendType=setBackendType(backendType);
|
||||||
file=new MyFile(this.getGcubeMemoryType());
|
file=new RequestObject(this.getGcubeMemoryType());
|
||||||
// put(true);
|
// put(true);
|
||||||
setCurrentOperation("getRemotePath");
|
setCurrentOperation("getRemotePath");
|
||||||
file=setOperationInfo(file, OPERATION.GET_REMOTE_PATH);
|
file=setOperationInfo(file, OPERATION.GET_REMOTE_PATH);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
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.TransportManagerFactory;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.UploadOperator;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.UploadOperator;
|
||||||
|
@ -29,7 +29,7 @@ public class ChunkConsumer implements Runnable {
|
||||||
boolean isChunk=false;
|
boolean isChunk=false;
|
||||||
String[] dbNames;
|
String[] dbNames;
|
||||||
public static ThreadLocal<TransportManager> client=new ThreadLocal<TransportManager>();
|
public static ThreadLocal<TransportManager> client=new ThreadLocal<TransportManager>();
|
||||||
public static ThreadLocal<MyFile> resource=new ThreadLocal<MyFile>();
|
public static ThreadLocal<RequestObject> resource=new ThreadLocal<RequestObject>();
|
||||||
private boolean replaceOpt;
|
private boolean replaceOpt;
|
||||||
Thread producer;
|
Thread producer;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class ChunkConsumer implements Runnable {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("run() - start");
|
logger.debug("run() - start");
|
||||||
}
|
}
|
||||||
MyFile request = null;
|
RequestObject request = null;
|
||||||
synchronized (ChunkConsumer.class) {
|
synchronized (ChunkConsumer.class) {
|
||||||
request=monitor.getRequest();
|
request=monitor.getRequest();
|
||||||
resource.set(request);
|
resource.set(request);
|
||||||
|
@ -49,7 +49,7 @@ public class ChunkConsumer implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connection(MyFile richiesta) {
|
private void connection(RequestObject richiesta) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("connection(MyFile) - start");
|
logger.debug("connection(MyFile) - start");
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class ChunkConsumer implements Runnable {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putInTerrastore(MyFile 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: "
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class ChunkProducer implements Runnable{
|
public class ChunkProducer implements Runnable{
|
||||||
|
|
||||||
MyFile resource;
|
RequestObject resource;
|
||||||
long dimensionChunk;
|
long dimensionChunk;
|
||||||
int totChunks;
|
int totChunks;
|
||||||
int nThreads;
|
int nThreads;
|
||||||
|
@ -31,8 +31,8 @@ public class ChunkProducer implements Runnable{
|
||||||
String bucketName;
|
String bucketName;
|
||||||
final Logger logger=LoggerFactory.getLogger(ChunkProducer.class);
|
final Logger logger=LoggerFactory.getLogger(ChunkProducer.class);
|
||||||
|
|
||||||
public ChunkProducer(Monitor monitor, MyFile 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;
|
||||||
|
@ -77,7 +77,7 @@ public class ChunkProducer implements Runnable{
|
||||||
//---- creo i task e li invio al thread-pool ----
|
//---- creo i task e li invio al thread-pool ----
|
||||||
String key= getBucketName()+i;
|
String key= getBucketName()+i;
|
||||||
resource.setKey(key);
|
resource.setKey(key);
|
||||||
MyFile copy=resource.copyProperties();
|
RequestObject copy=resource.copyProperties();
|
||||||
copy.setContent(chunk);
|
copy.setContent(chunk);
|
||||||
if(logger.isDebugEnabled()){
|
if(logger.isDebugEnabled()){
|
||||||
logger.debug("request in queue: "+key);
|
logger.debug("request in queue: "+key);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -18,13 +18,13 @@ public abstract class Copy extends Operation{
|
||||||
final Logger logger=LoggerFactory.getLogger(Copy.class);
|
final Logger logger=LoggerFactory.getLogger(Copy.class);
|
||||||
protected String sourcePath;
|
protected String sourcePath;
|
||||||
protected String destinationPath;
|
protected String destinationPath;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
public Copy(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public Copy(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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);
|
||||||
|
@ -52,8 +52,8 @@ public abstract class Copy extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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();
|
||||||
|
@ -67,12 +67,12 @@ public abstract class Copy extends Operation{
|
||||||
|
|
||||||
// public abstract String execute(MongoIO mongoPrimaryInstance) throws UnknownHostException;
|
// public abstract String execute(MongoIO mongoPrimaryInstance) throws UnknownHostException;
|
||||||
|
|
||||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
public abstract String execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -22,14 +22,14 @@ public abstract class CopyDir extends Operation{
|
||||||
final Logger logger=LoggerFactory.getLogger(Download.class);
|
final Logger logger=LoggerFactory.getLogger(Download.class);
|
||||||
private String sourcePath;
|
private String sourcePath;
|
||||||
private String destinationPath;
|
private String destinationPath;
|
||||||
private MyFile resource;
|
private RequestObject resource;
|
||||||
|
|
||||||
public CopyDir(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public CopyDir(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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);
|
||||||
|
@ -57,8 +57,8 @@ public abstract class CopyDir extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -70,7 +70,7 @@ public abstract class CopyDir extends Operation{
|
||||||
return bucket=destinationPath;
|
return bucket=destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<String> execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
public abstract List<String> execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||||
|
|
||||||
public String getSourcePath() {
|
public String getSourcePath() {
|
||||||
return sourcePath;
|
return sourcePath;
|
||||||
|
@ -88,11 +88,11 @@ public abstract class CopyDir extends Operation{
|
||||||
this.destinationPath = destinationPath;
|
this.destinationPath = destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -26,35 +26,35 @@ public abstract class Download extends Operation{
|
||||||
protected String localPath;
|
protected String localPath;
|
||||||
protected String remotePath;
|
protected String remotePath;
|
||||||
protected OutputStream os;
|
protected OutputStream os;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
|
|
||||||
public Download(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public Download(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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());
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,8 @@ public abstract class Download extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -76,11 +76,11 @@ public abstract class Download extends Operation{
|
||||||
|
|
||||||
public abstract ObjectId execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance) throws IOException;
|
public abstract ObjectId execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance) throws IOException;
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
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;
|
||||||
|
@ -29,17 +29,17 @@ public class DownloadAndLock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String doIt(MyFile 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());
|
||||||
}
|
}
|
||||||
|
@ -47,17 +47,17 @@ public class DownloadAndLock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -23,14 +23,14 @@ public abstract class DuplicateFile extends Operation {
|
||||||
*/
|
*/
|
||||||
final Logger logger=LoggerFactory.getLogger(DuplicateFile.class);
|
final Logger logger=LoggerFactory.getLogger(DuplicateFile.class);
|
||||||
protected String sourcePath;
|
protected String sourcePath;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
|
|
||||||
public DuplicateFile(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public DuplicateFile(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String doIt(MyFile 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(MyFile 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);
|
||||||
|
@ -64,8 +64,8 @@ public abstract class DuplicateFile extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@ public abstract class DuplicateFile extends Operation {
|
||||||
this.sourcePath = sourcePath;
|
this.sourcePath = sourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.BucketCoding;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.BucketCoding;
|
||||||
|
@ -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(MyFile 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);
|
||||||
|
@ -44,8 +44,8 @@ public class Exist extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -61,8 +61,8 @@ public class Exist extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
//import org.apache.log4j.Logger;
|
//import org.apache.log4j.Logger;
|
||||||
//import org.gcube.common.core.utils.logging.GCUBELog;
|
//import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -31,7 +31,7 @@ public class FileWriter extends Thread{
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("run() - start");
|
logger.debug("run() - start");
|
||||||
}
|
}
|
||||||
MyFile request = monitor.getRequest();
|
RequestObject request = monitor.getRequest();
|
||||||
synchronized (FileWriter.class) {
|
synchronized (FileWriter.class) {
|
||||||
if(logger.isDebugEnabled()){
|
if(logger.isDebugEnabled()){
|
||||||
logger.debug("recover request: "+request.getKey()+" length: "+request.getContent().length);
|
logger.debug("recover request: "+request.getKey()+" length: "+request.getContent().length);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -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(MyFile 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) {
|
||||||
|
@ -30,15 +30,15 @@ public class ForceClose extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.service.directoryOperation.DirectoryBucket;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -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(MyFile 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);
|
||||||
|
@ -35,8 +35,8 @@ public class GetFolderCount extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
|
@ -53,8 +53,8 @@ public class GetFolderCount extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.service.directoryOperation.DirectoryBucket;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -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(MyFile myFile) throws RemoteBackendException{
|
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -43,8 +43,8 @@ public class GetFolderLastUpdate extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.service.directoryOperation.DirectoryBucket;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -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(MyFile 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);
|
||||||
|
@ -35,8 +35,8 @@ public class GetFolderSize extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -55,8 +55,8 @@ public class GetFolderSize extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter.EncryptionException;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter.EncryptionException;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -33,28 +33,28 @@ public class GetHttpUrl extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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(MyFile 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(MyFile 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(MyFile 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()); }
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.net.URL;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter.EncryptionException;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter.EncryptionException;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -29,28 +29,28 @@ public class GetHttpsUrl extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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(MyFile 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(MyFile 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(MyFile 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);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -29,20 +29,20 @@ public class GetMetaFile extends Operation{
|
||||||
* size.
|
* size.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public MyFile doIt(MyFile 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(MyFile 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);
|
||||||
|
@ -75,8 +75,8 @@ public class GetMetaFile extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -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(MyFile 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()); }
|
||||||
|
@ -35,8 +35,8 @@ public class GetMetaInfo extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -52,8 +52,8 @@ public class GetMetaInfo extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -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(MyFile 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);
|
||||||
|
@ -42,8 +42,8 @@ public class GetRemotePath extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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())
|
||||||
|
@ -58,8 +58,8 @@ public class GetRemotePath extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -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(MyFile 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()); }
|
||||||
|
@ -41,8 +41,8 @@ public class GetSize extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
|
@ -57,8 +57,8 @@ public class GetSize extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -26,16 +26,16 @@ public class GetTTL extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String doIt(MyFile 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();
|
||||||
|
@ -45,9 +45,9 @@ public class GetTTL extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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,8 +57,8 @@ public class GetTTL extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter.EncryptionException;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.Encrypter.EncryptionException;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -25,35 +25,35 @@ public class GetUrl extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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(MyFile 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(MyFile 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(MyFile 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()); }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.service.directoryOperation.DirectoryBucket;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -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(MyFile 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 {
|
||||||
|
@ -35,8 +35,8 @@ public class GetUserTotalItems extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -61,8 +61,8 @@ public class GetUserTotalItems extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.service.directoryOperation.DirectoryBucket;
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
||||||
|
@ -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(MyFile 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 {
|
||||||
|
@ -34,8 +34,8 @@ public class GetUserTotalVolume extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -59,8 +59,8 @@ public class GetUserTotalVolume extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -19,13 +19,13 @@ public abstract class Link extends Operation{
|
||||||
final Logger logger=LoggerFactory.getLogger(Download.class);
|
final Logger logger=LoggerFactory.getLogger(Download.class);
|
||||||
private String sourcePath;
|
private String sourcePath;
|
||||||
private String destinationPath;
|
private String destinationPath;
|
||||||
private MyFile resource;
|
private RequestObject resource;
|
||||||
public Link(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public Link(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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);
|
||||||
|
@ -50,8 +50,8 @@ public abstract class Link extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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();
|
||||||
|
@ -62,7 +62,7 @@ public abstract class Link extends Operation{
|
||||||
return bucket=destinationPath;
|
return bucket=destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||||
|
|
||||||
public String getSourcePath() {
|
public String getSourcePath() {
|
||||||
return sourcePath;
|
return sourcePath;
|
||||||
|
@ -80,11 +80,11 @@ public abstract class Link extends Operation{
|
||||||
this.destinationPath = destinationPath;
|
this.destinationPath = destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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;
|
||||||
|
@ -24,7 +23,7 @@ public abstract class Lock extends Operation {
|
||||||
protected String localPath;
|
protected String localPath;
|
||||||
protected String remotePath;
|
protected String remotePath;
|
||||||
protected OutputStream os;
|
protected OutputStream os;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
protected Download download;
|
protected Download download;
|
||||||
|
|
||||||
public Lock(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public Lock(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
|
@ -33,18 +32,18 @@ public abstract class Lock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String doIt(MyFile 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());
|
||||||
}
|
}
|
||||||
|
@ -52,9 +51,9 @@ public abstract class Lock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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
|
||||||
|
@ -71,13 +70,13 @@ public abstract class Lock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String serverLocation) throws Exception;
|
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String serverLocation) throws Exception;
|
||||||
|
|
||||||
public String getLocalPath() {
|
public String getLocalPath() {
|
||||||
return localPath;
|
return localPath;
|
||||||
|
@ -103,11 +102,11 @@ public abstract class Lock extends Operation {
|
||||||
this.os = os;
|
this.os = os;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
//import org.apache.log4j.Logger;
|
//import org.apache.log4j.Logger;
|
||||||
//import org.gcube.common.core.utils.logging.GCUBELog;
|
//import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -22,9 +22,9 @@ 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<MyFile> requestQueue = new Vector<MyFile>();
|
private Vector<RequestObject> requestQueue = new Vector<RequestObject>();
|
||||||
// fetch the first request in the queue
|
// fetch the first request in the queue
|
||||||
public synchronized MyFile getRequest(){
|
public synchronized RequestObject getRequest(){
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("getRequest() - start");
|
logger.debug("getRequest() - start");
|
||||||
}
|
}
|
||||||
|
@ -36,15 +36,15 @@ public class Monitor {
|
||||||
logger.error("getRequest()", e);
|
logger.error("getRequest()", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MyFile 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 MyFile getRequest(ChunkProducer producer){
|
public synchronized RequestObject getRequest(ChunkProducer producer){
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("getRequest(ChunkProducer) - start");
|
logger.debug("getRequest(ChunkProducer) - start");
|
||||||
}
|
}
|
||||||
|
@ -56,16 +56,16 @@ public class Monitor {
|
||||||
logger.error("getRequest(ChunkProducer)", e);
|
logger.error("getRequest(ChunkProducer)", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MyFile 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
|
||||||
public synchronized void putRequest(MyFile richiesta){
|
public synchronized void putRequest(RequestObject richiesta){
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("putRequest(MyFile) - start");
|
logger.debug("putRequest(MyFile) - start");
|
||||||
logger.debug("request in queue, queue size: "+requestQueue.size());
|
logger.debug("request in queue, queue size: "+requestQueue.size());
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -20,13 +20,13 @@ public abstract class Move extends Operation{
|
||||||
final Logger logger=LoggerFactory.getLogger(Download.class);
|
final Logger logger=LoggerFactory.getLogger(Download.class);
|
||||||
protected String sourcePath;
|
protected String sourcePath;
|
||||||
protected String destinationPath;
|
protected String destinationPath;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
public Move(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public Move(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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);
|
||||||
|
@ -51,8 +51,8 @@ public abstract class Move extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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, MyFile 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;
|
||||||
|
@ -79,11 +79,11 @@ public abstract class Move extends Operation{
|
||||||
this.destinationPath = destinationPath;
|
this.destinationPath = destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.net.UnknownHostException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -20,14 +20,14 @@ public abstract class MoveDir extends Operation{
|
||||||
final Logger logger=LoggerFactory.getLogger(Download.class);
|
final Logger logger=LoggerFactory.getLogger(Download.class);
|
||||||
private String sourcePath;
|
private String sourcePath;
|
||||||
private String destinationPath;
|
private String destinationPath;
|
||||||
private MyFile resource;
|
private RequestObject resource;
|
||||||
// private OutputStream os;
|
// private OutputStream os;
|
||||||
public MoveDir(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public MoveDir(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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);
|
||||||
|
@ -52,8 +52,8 @@ public abstract class MoveDir extends Operation{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -62,7 +62,7 @@ public abstract class MoveDir extends Operation{
|
||||||
return bucket=destinationPath;
|
return bucket=destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<String> execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath, MemoryType memoryType) throws UnknownHostException;
|
public abstract List<String> execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath, MemoryType memoryType) throws UnknownHostException;
|
||||||
|
|
||||||
public String getSourcePath() {
|
public String getSourcePath() {
|
||||||
return sourcePath;
|
return sourcePath;
|
||||||
|
@ -80,11 +80,11 @@ public abstract class MoveDir extends Operation{
|
||||||
this.destinationPath = destinationPath;
|
this.destinationPath = destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.TransportManagerFactory;
|
||||||
|
@ -99,7 +99,7 @@ public abstract class Operation {
|
||||||
* @return a String that identifies a file
|
* @return a String that identifies a file
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String put(Upload upload, MyFile resource, boolean isChunk, boolean isBase64, boolean replaceOption, boolean isLock) throws Exception{
|
public String put(Upload upload, RequestObject resource, boolean isChunk, boolean isBase64, boolean replaceOption, boolean isLock) throws Exception{
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("put(MyFile, boolean, boolean) - start");
|
logger.debug("put(MyFile, boolean, boolean) - start");
|
||||||
}
|
}
|
||||||
|
@ -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, MyFile 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, MyFile.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,19 +198,19 @@ 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
|
||||||
*/
|
*/
|
||||||
protected void startPThreadChunk(Download download,MyFile myFile, TransportManager tm,
|
protected void startPThreadChunk(Download download, RequestObject requestObject, TransportManager tm,
|
||||||
String path) throws FileNotFoundException, InterruptedException,
|
String path) throws FileNotFoundException, InterruptedException,
|
||||||
IOException {
|
IOException {
|
||||||
ExecutorService executor = Executors.newFixedThreadPool (2);
|
ExecutorService executor = Executors.newFixedThreadPool (2);
|
||||||
int j=0;
|
int j=0;
|
||||||
MyFile value=null;
|
RequestObject value=null;
|
||||||
|
|
||||||
if(logger.isInfoEnabled())
|
if(logger.isInfoEnabled())
|
||||||
logger.info("localPath: "+path+" bucket: "+bucket);
|
logger.info("localPath: "+path+" bucket: "+bucket);
|
||||||
|
@ -224,7 +224,7 @@ public abstract class Operation {
|
||||||
logger.debug("get(String) -");
|
logger.debug("get(String) -");
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
value=(MyFile) tm.get(download);
|
value=(RequestObject) tm.get(download);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("get(String) - \n Trovate " + (j) + " key");
|
logger.debug("get(String) - \n Trovate " + (j) + " key");
|
||||||
|
@ -274,11 +274,11 @@ 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
|
||||||
*/
|
*/
|
||||||
public abstract Object doIt(MyFile myFile) throws RemoteBackendException;
|
public abstract Object doIt(RequestObject requestObject) throws RemoteBackendException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init a operation
|
* init a operation
|
||||||
|
@ -290,7 +290,7 @@ public abstract class Operation {
|
||||||
* @param replaceOption if true the file will be replaced
|
* @param replaceOption if true the file will be replaced
|
||||||
* @return a string that identifies the operation
|
* @return a string that identifies the operation
|
||||||
*/
|
*/
|
||||||
public abstract String initOperation(MyFile file, String remoteIdentifier, String author, String[] server, String rootArea, boolean replaceOption);
|
public abstract String initOperation(RequestObject file, String remoteIdentifier, String author, String[] server, String rootArea, boolean replaceOption);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,7 +302,7 @@ public abstract class Operation {
|
||||||
* @param rootArea remote root path
|
* @param rootArea remote root path
|
||||||
* @return a string that identifies the operation
|
* @return a string that identifies the operation
|
||||||
*/
|
*/
|
||||||
public abstract String initOperation(MyFile resource, String remoteIdentifier, String author, String[] server, String rootArea);
|
public abstract String initOperation(RequestObject resource, String remoteIdentifier, String author, String[] server, String rootArea);
|
||||||
|
|
||||||
public String getOwner() {
|
public String getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
|
@ -394,7 +394,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;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -21,7 +21,7 @@ public class OperationManager {
|
||||||
private String[] server;
|
private String[] server;
|
||||||
// private int dimension;
|
// private int dimension;
|
||||||
private String operation;
|
private String operation;
|
||||||
private MyFile resource;
|
private RequestObject resource;
|
||||||
private boolean isChunk;
|
private boolean isChunk;
|
||||||
private String bucketName;
|
private String bucketName;
|
||||||
private String fileDest;
|
private String fileDest;
|
||||||
|
@ -33,12 +33,12 @@ public class OperationManager {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public OperationManager(String[] server, String user, String password, String operation, MyFile 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;
|
||||||
|
@ -124,11 +124,11 @@ public class OperationManager {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -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(MyFile 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);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ public class Remove extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -61,7 +61,7 @@ public class Remove extends Operation{
|
||||||
* @param bucketName indicates the remote directory to remove
|
* @param bucketName indicates the remote directory to remove
|
||||||
* @throws RemoteBackendException
|
* @throws RemoteBackendException
|
||||||
*/
|
*/
|
||||||
public void removeBucket(TransportManager tm, String bucketName, MyFile resource) throws RemoteBackendException {
|
public void removeBucket(TransportManager tm, String bucketName, RequestObject resource) throws RemoteBackendException {
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
logger.debug("removing file bucket: "+bucketName);
|
logger.debug("removing file bucket: "+bucketName);
|
||||||
try {
|
try {
|
||||||
|
@ -74,8 +74,8 @@ public class Remove extends Operation{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -28,12 +28,12 @@ public class RenewTTL extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String doIt(MyFile 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());
|
||||||
|
@ -42,9 +42,9 @@ public class RenewTTL extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -53,8 +53,8 @@ public class RenewTTL extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.RemoteBackendException;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
@ -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(MyFile 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();
|
||||||
|
@ -35,8 +35,8 @@ public class SetMetaInfo extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
|
@ -51,8 +51,8 @@ public class SetMetaInfo extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -25,14 +25,14 @@ public abstract class SoftCopy extends Operation {
|
||||||
final Logger logger=LoggerFactory.getLogger(SoftCopy.class);
|
final Logger logger=LoggerFactory.getLogger(SoftCopy.class);
|
||||||
private String sourcePath;
|
private String sourcePath;
|
||||||
private String destinationPath;
|
private String destinationPath;
|
||||||
private MyFile resource;
|
private RequestObject resource;
|
||||||
|
|
||||||
|
|
||||||
public SoftCopy(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public SoftCopy(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String initOperation(MyFile 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(MyFile 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);
|
||||||
|
@ -57,7 +57,7 @@ public abstract class SoftCopy extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile resource, String remotePath, String author, String[] server, String rootArea) {
|
public String initOperation(RequestObject resource, String remotePath, 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();
|
||||||
|
@ -67,7 +67,7 @@ public abstract class SoftCopy extends Operation {
|
||||||
return bucket=destinationPath;
|
return bucket=destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
public abstract String execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
|
||||||
|
|
||||||
public String getSourcePath() {
|
public String getSourcePath() {
|
||||||
return sourcePath;
|
return sourcePath;
|
||||||
|
@ -85,11 +85,11 @@ public abstract class SoftCopy extends Operation {
|
||||||
this.destinationPath = destinationPath;
|
this.destinationPath = destinationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -22,7 +22,7 @@ public abstract class Unlock extends Operation {
|
||||||
protected String localPath;
|
protected String localPath;
|
||||||
protected String remotePath;
|
protected String remotePath;
|
||||||
protected OutputStream os;
|
protected OutputStream os;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
protected Upload upload;
|
protected Upload upload;
|
||||||
|
|
||||||
public Unlock(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
public Unlock(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
||||||
|
@ -31,18 +31,18 @@ public abstract class Unlock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String doIt(MyFile 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());
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ public abstract class Unlock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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))){
|
||||||
|
@ -68,13 +68,13 @@ public abstract class Unlock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String bucket, String key4unlock) throws Exception;
|
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String bucket, String key4unlock) throws Exception;
|
||||||
|
|
||||||
public String getLocalPath() {
|
public String getLocalPath() {
|
||||||
return localPath;
|
return localPath;
|
||||||
|
@ -100,11 +100,11 @@ public abstract class Unlock extends Operation {
|
||||||
this.os = os;
|
this.os = os;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.backend.MongoIOManager;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
|
||||||
|
@ -31,7 +31,7 @@ public abstract class Upload extends Operation {
|
||||||
protected String localPath;
|
protected String localPath;
|
||||||
protected String remotePath;
|
protected String remotePath;
|
||||||
protected OutputStream os;
|
protected OutputStream os;
|
||||||
protected MyFile resource;
|
protected RequestObject resource;
|
||||||
|
|
||||||
public Upload(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String bck, String[] dbs) {
|
public Upload(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String bck, String[] dbs) {
|
||||||
super(server, user, pwd, bucket, monitor, isChunk, bck, dbs);
|
super(server, user, pwd, bucket, monitor, isChunk, bck, dbs);
|
||||||
|
@ -39,19 +39,19 @@ public abstract class Upload extends Operation {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String doIt(MyFile 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;
|
||||||
|
@ -61,7 +61,7 @@ public abstract class Upload extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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) {
|
||||||
// set replace option
|
// set replace option
|
||||||
this.replaceOption=replaceOption;
|
this.replaceOption=replaceOption;
|
||||||
setResource(file);
|
setResource(file);
|
||||||
|
@ -78,8 +78,8 @@ public abstract class Upload extends Operation {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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);
|
||||||
|
@ -88,7 +88,7 @@ public abstract class Upload extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String bucket, boolean replace) throws IOException;
|
public abstract String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String bucket, boolean replace) throws IOException;
|
||||||
|
|
||||||
public InputStream getIs() {
|
public InputStream getIs() {
|
||||||
return is;
|
return is;
|
||||||
|
@ -150,13 +150,13 @@ public abstract class Upload extends Operation {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.service.operation;
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.TransportManagerFactory;
|
||||||
|
@ -21,19 +21,19 @@ public class UploadAndUnlock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String doIt(MyFile 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());
|
||||||
}
|
}
|
||||||
Upload upload= new UploadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
Upload upload= new UploadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||||
String objectId=null;
|
String objectId=null;
|
||||||
try {
|
try {
|
||||||
//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) {
|
||||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||||
TransportManager tm=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
TransportManager tm=tmf.getTransport(transport, backendType, requestObject.getGcubeMemoryType(), dbNames, requestObject.getWriteConcern(), requestObject.getReadPreference());
|
||||||
tm.close();
|
tm.close();
|
||||||
throw new RemoteBackendException(" Error in uploadAndUnlock operation ", e);
|
throw new RemoteBackendException(" Error in uploadAndUnlock operation ", e);
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ public class UploadAndUnlock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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) {
|
||||||
// set replace option
|
// set replace option
|
||||||
// this.replaceOption=replaceOption;
|
// this.replaceOption=replaceOption;
|
||||||
// the name of bucket is formed: path_____fileName_____author
|
// the name of bucket is formed: path_____fileName_____author
|
||||||
|
@ -54,8 +54,8 @@ public class UploadAndUnlock extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String initOperation(MyFile 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.*;
|
import org.gcube.contentmanagement.blobstorage.service.operation.*;
|
||||||
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.LockOperator;
|
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.LockOperator;
|
||||||
|
@ -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, MyFile 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{
|
||||||
|
@ -76,7 +76,7 @@ public abstract class TransportManager {
|
||||||
*/
|
*/
|
||||||
public String uploadManager(Upload upload, Object resource, String bucket, String key, boolean replace) throws Exception{
|
public String uploadManager(Upload upload, Object resource, String bucket, String key, boolean replace) throws Exception{
|
||||||
String id=null;
|
String id=null;
|
||||||
MyFile file=(MyFile)resource;
|
RequestObject file=(RequestObject)resource;
|
||||||
if((file.getLockedKey()!=null) && (!file.getLockedKey().isEmpty())){
|
if((file.getLockedKey()!=null) && (!file.getLockedKey().isEmpty())){
|
||||||
Unlock unlock= new UnlockOperator(upload.getServer(), upload.getUser(), upload.getPassword(), upload.getBucket(), upload.getMonitor(), upload.isChunk(), upload.getBackendType(), upload.getDbNames());
|
Unlock unlock= new UnlockOperator(upload.getServer(), upload.getUser(), upload.getPassword(), upload.getBucket(), upload.getMonitor(), upload.isChunk(), upload.getBackendType(), upload.getDbNames());
|
||||||
unlock.setResource(file);
|
unlock.setResource(file);
|
||||||
|
@ -133,34 +133,34 @@ public abstract class TransportManager {
|
||||||
* @return map that contains the object in the direcotry
|
* @return map that contains the object in the direcotry
|
||||||
* @throws UnknownHostException
|
* @throws UnknownHostException
|
||||||
*/
|
*/
|
||||||
public abstract Map<String, StorageObject> getValues(MyFile resource, String bucket, Class< ? extends Object> type);
|
public abstract Map<String, StorageObject> getValues(RequestObject resource, String bucket, Class< ? extends Object> type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a remote file
|
* delete a remote file
|
||||||
* @param bucket identifies the remote file
|
* @param bucket identifies the remote file
|
||||||
* @throws UnknownHostException
|
* @throws UnknownHostException
|
||||||
*/
|
*/
|
||||||
public abstract void removeRemoteFile(String bucket, MyFile resource) throws UnknownHostException;
|
public abstract void removeRemoteFile(String bucket, RequestObject resource) throws UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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, MyFile 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, MyFile myFile);
|
public abstract long getSize(String bucket, RequestObject requestObject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lock a remote file
|
* lock a remote file
|
||||||
|
@ -210,7 +210,7 @@ public abstract class TransportManager {
|
||||||
* @throws UnknownHostException
|
* @throws UnknownHostException
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
*/
|
*/
|
||||||
public abstract long renewTTL(MyFile resource) throws UnknownHostException, IllegalAccessException;
|
public abstract long renewTTL(RequestObject resource) throws UnknownHostException, IllegalAccessException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
|
@ -123,7 +123,7 @@ public class MongoIOManager {
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
//PATCHED METHODS
|
//PATCHED METHODS
|
||||||
protected ObjectId getRemoteObject(GridFS gfs, MyFile resource, GridFSDBFile f) throws IOException, IllegalAccessError {
|
protected ObjectId getRemoteObject(GridFS gfs, RequestObject resource, GridFSDBFile f) throws IOException, IllegalAccessError {
|
||||||
ObjectId id;
|
ObjectId id;
|
||||||
id=(ObjectId)f.getId();
|
id=(ObjectId)f.getId();
|
||||||
String lock=(String)f.get("lock");
|
String lock=(String)f.get("lock");
|
||||||
|
@ -139,7 +139,7 @@ public class MongoIOManager {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectId getRemoteObject(MyFile resource, GridFSDBFile f) throws IOException, IllegalAccessError {
|
public ObjectId getRemoteObject(RequestObject resource, GridFSDBFile f) throws IOException, IllegalAccessError {
|
||||||
ObjectId id;
|
ObjectId id;
|
||||||
id=(ObjectId)f.getId();
|
id=(ObjectId)f.getId();
|
||||||
String lock=(String)f.get("lock");
|
String lock=(String)f.get("lock");
|
||||||
|
@ -185,7 +185,7 @@ 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
|
||||||
*/
|
*/
|
||||||
private void download(GridFS gfs, MyFile resource, GridFSDBFile f, boolean isLock) throws IOException {
|
private void download(GridFS gfs, RequestObject resource, GridFSDBFile f, boolean isLock) throws IOException {
|
||||||
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
|
||||||
|
@ -216,7 +216,7 @@ 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
|
||||||
*/
|
*/
|
||||||
private void download( MyFile resource, GridFSDBFile f, boolean isLock) throws IOException {
|
private void download(RequestObject resource, GridFSDBFile f, boolean isLock) throws IOException {
|
||||||
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
|
||||||
|
@ -240,7 +240,7 @@ public class MongoIOManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCommonFields(DBObject f, MyFile resource, OPERATION op) {
|
public void updateCommonFields(DBObject f, RequestObject resource, OPERATION op) {
|
||||||
f.put("lastAccess", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
f.put("lastAccess", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
||||||
String owner=resource.getOwner();
|
String owner=resource.getOwner();
|
||||||
f.put("lastUser", owner);
|
f.put("lastUser", owner);
|
||||||
|
@ -287,7 +287,7 @@ public class MongoIOManager {
|
||||||
close();
|
close();
|
||||||
throw new IllegalAccessError("The file is locked");
|
throw new IllegalAccessError("The file is locked");
|
||||||
}else{
|
}else{
|
||||||
oldId=checkAndRemove(fold, (MyFile)resource);
|
oldId=checkAndRemove(fold, (RequestObject)resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }else if(oldir == null){
|
// }else if(oldir == null){
|
||||||
|
@ -299,7 +299,7 @@ public class MongoIOManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ObjectId checkAndRemove(GridFSDBFile f, MyFile resource){
|
public ObjectId checkAndRemove(GridFSDBFile f, RequestObject resource){
|
||||||
String idToRemove=f.getId().toString();
|
String idToRemove=f.getId().toString();
|
||||||
logger.info("check and remove object with id "+idToRemove+" and path: "+f.get("filename"));
|
logger.info("check and remove object with id "+idToRemove+" and path: "+f.get("filename"));
|
||||||
ObjectId idFile=null;
|
ObjectId idFile=null;
|
||||||
|
@ -408,12 +408,12 @@ public class MongoIOManager {
|
||||||
//maybe this close is not needed
|
//maybe this close is not needed
|
||||||
// clean();
|
// clean();
|
||||||
try{
|
try{
|
||||||
if(((MyFile)resource).getInputStream()!= null){
|
if(((RequestObject)resource).getInputStream()!= null){
|
||||||
//upload with client inputStream
|
//upload with client inputStream
|
||||||
f2 = writeByInputStream(resource, bucket, name, dir,idFile);
|
f2 = writeByInputStream(resource, bucket, name, dir,idFile);
|
||||||
f2.save();
|
f2.save();
|
||||||
|
|
||||||
}else if(((((MyFile)resource).getType() != null) && (((MyFile)resource).getType().equals("output")))){
|
}else if(((((RequestObject)resource).getType() != null) && (((RequestObject)resource).getType().equals("output")))){
|
||||||
// upload with outputstream
|
// upload with outputstream
|
||||||
f2 = writeByOutputStream(resource, bucket, name, dir, idFile);
|
f2 = writeByOutputStream(resource, bucket, name, dir, idFile);
|
||||||
}else{
|
}else{
|
||||||
|
@ -429,7 +429,7 @@ public class MongoIOManager {
|
||||||
logger.debug("ObjectId: "+id);
|
logger.debug("ObjectId: "+id);
|
||||||
|
|
||||||
// if it is an outputstream don't close
|
// if it is an outputstream don't close
|
||||||
if(!((((MyFile)resource).getType() != null) && (((MyFile)resource).getType().equals("output")))){
|
if(!((((RequestObject)resource).getType() != null) && (((RequestObject)resource).getType().equals("output")))){
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}catch(IOException e1){
|
}catch(IOException e1){
|
||||||
|
@ -454,9 +454,9 @@ public class MongoIOManager {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
GridFSInputFile f2;
|
GridFSInputFile f2;
|
||||||
if(!(memoryType== MemoryType.VOLATILE))
|
if(!(memoryType== MemoryType.VOLATILE))
|
||||||
f2 = createGFSFileObject(new File(((MyFile)resource).getLocalPath()), ((MyFile)resource).getWriteConcern(), ((MyFile)resource).getReadPreference());
|
f2 = createGFSFileObject(new File(((RequestObject)resource).getLocalPath()), ((RequestObject)resource).getWriteConcern(), ((RequestObject)resource).getReadPreference());
|
||||||
else
|
else
|
||||||
f2 = createGFSFileObject(new File(((MyFile)resource).getLocalPath()));
|
f2 = createGFSFileObject(new File(((RequestObject)resource).getLocalPath()));
|
||||||
fillInputFile(resource, bucket, name, dir, f2, idFile);
|
fillInputFile(resource, bucket, name, dir, f2, idFile);
|
||||||
saveGFSFileObject(f2);
|
saveGFSFileObject(f2);
|
||||||
return f2;
|
return f2;
|
||||||
|
@ -466,11 +466,11 @@ public class MongoIOManager {
|
||||||
String bucket, String name, String dir, ObjectId idFile) throws IOException {
|
String bucket, String name, String dir, ObjectId idFile) throws IOException {
|
||||||
GridFSInputFile f2;
|
GridFSInputFile f2;
|
||||||
if(!(memoryType== MemoryType.VOLATILE))
|
if(!(memoryType== MemoryType.VOLATILE))
|
||||||
f2 = createGFSFileObject(((MyFile)resource).getName(), ((MyFile)resource).getWriteConcern(), ((MyFile)resource).getReadPreference());
|
f2 = createGFSFileObject(((RequestObject)resource).getName(), ((RequestObject)resource).getWriteConcern(), ((RequestObject)resource).getReadPreference());
|
||||||
else
|
else
|
||||||
f2 = createGFSFileObject(((MyFile)resource).getName());
|
f2 = createGFSFileObject(((RequestObject)resource).getName());
|
||||||
fillInputFile(resource, bucket, name, dir, f2, idFile);
|
fillInputFile(resource, bucket, name, dir, f2, idFile);
|
||||||
((MyFile)resource).setOutputStream(new MongoOutputStream(mongo, f2.getOutputStream()));
|
((RequestObject)resource).setOutputStream(new MongoOutputStream(mongo, f2.getOutputStream()));
|
||||||
return f2;
|
return f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,13 +479,13 @@ public class MongoIOManager {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
GridFSInputFile f2;
|
GridFSInputFile f2;
|
||||||
if(!(memoryType== MemoryType.VOLATILE))
|
if(!(memoryType== MemoryType.VOLATILE))
|
||||||
f2 = createGFSFileObject(((MyFile)resource).getInputStream(), ((MyFile)resource).getWriteConcern(),((MyFile)resource).getReadPreference());
|
f2 = createGFSFileObject(((RequestObject)resource).getInputStream(), ((RequestObject)resource).getWriteConcern(),((RequestObject)resource).getReadPreference());
|
||||||
else
|
else
|
||||||
f2 = createGFSFileObject(((MyFile)resource).getInputStream());
|
f2 = createGFSFileObject(((RequestObject)resource).getInputStream());
|
||||||
fillInputFile(resource, bucket, name, dir, f2, idFile);
|
fillInputFile(resource, bucket, name, dir, f2, idFile);
|
||||||
saveGFSFileObject(f2);
|
saveGFSFileObject(f2);
|
||||||
((MyFile)resource).getInputStream().close();
|
((RequestObject)resource).getInputStream().close();
|
||||||
((MyFile)resource).setInputStream(null);
|
((RequestObject)resource).setInputStream(null);
|
||||||
return f2;
|
return f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,14 +503,14 @@ public class MongoIOManager {
|
||||||
f2.put("name", name);
|
f2.put("name", name);
|
||||||
if(dir!=null)
|
if(dir!=null)
|
||||||
f2.put("dir", dir);
|
f2.put("dir", dir);
|
||||||
if(((MyFile)resource).getOwner() !=null)
|
if(((RequestObject)resource).getOwner() !=null)
|
||||||
f2.put("owner", ((MyFile)resource).getOwner());
|
f2.put("owner", ((RequestObject)resource).getOwner());
|
||||||
String mime= ((MyFile)resource).getMimeType();
|
String mime= ((RequestObject)resource).getMimeType();
|
||||||
if( mime !=null){
|
if( mime !=null){
|
||||||
f2.put("mimetype", mime);
|
f2.put("mimetype", mime);
|
||||||
}
|
}
|
||||||
f2.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
f2.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
||||||
updateCommonFields(f2, (MyFile)resource, null);
|
updateCommonFields(f2, (RequestObject)resource, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ public class MongoIOManager {
|
||||||
* @param query
|
* @param query
|
||||||
* @throws UnknownHostException
|
* @throws UnknownHostException
|
||||||
*/
|
*/
|
||||||
protected void removeObject(GridFS gfs, BasicDBObject query, MyFile resource){
|
protected void removeObject(GridFS gfs, BasicDBObject query, RequestObject resource){
|
||||||
List<GridFSDBFile> list = gfs.find(query);
|
List<GridFSDBFile> list = gfs.find(query);
|
||||||
for(Iterator<GridFSDBFile> it=list.iterator(); it.hasNext();){
|
for(Iterator<GridFSDBFile> it=list.iterator(); it.hasNext();){
|
||||||
GridFSDBFile f=(GridFSDBFile)it.next();
|
GridFSDBFile f=(GridFSDBFile)it.next();
|
||||||
|
@ -535,20 +535,20 @@ public class MongoIOManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setGenericProperties(MyFile resource, String destination,
|
public void setGenericProperties(RequestObject resource, String destination,
|
||||||
String dir, GridFSInputFile destinationFile, String name) {
|
String dir, GridFSInputFile destinationFile, String name) {
|
||||||
updateCommonFields(destinationFile, resource, null);
|
updateCommonFields(destinationFile, resource, null);
|
||||||
destinationFile.put("filename", destination);
|
destinationFile.put("filename", destination);
|
||||||
destinationFile.put("type", "file");
|
destinationFile.put("type", "file");
|
||||||
destinationFile.put("name", name);
|
destinationFile.put("name", name);
|
||||||
destinationFile.put("dir", dir);
|
destinationFile.put("dir", dir);
|
||||||
destinationFile.put("owner", ((MyFile)resource).getOwner());
|
destinationFile.put("owner", ((RequestObject)resource).getOwner());
|
||||||
destinationFile.put("mimetype", ((MyFile)resource).getMimeType());
|
destinationFile.put("mimetype", ((RequestObject)resource).getMimeType());
|
||||||
destinationFile.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
destinationFile.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DBObject setGenericMoveProperties(MyFile resource, String filename, String dir,
|
public DBObject setGenericMoveProperties(RequestObject resource, String filename, String dir,
|
||||||
String name, DBObject sourcePathMetaCollection) {
|
String name, DBObject sourcePathMetaCollection) {
|
||||||
sourcePathMetaCollection.put("filename", filename);
|
sourcePathMetaCollection.put("filename", filename);
|
||||||
sourcePathMetaCollection.put("type", "file");
|
sourcePathMetaCollection.put("type", "file");
|
||||||
sourcePathMetaCollection.put("name", name);
|
sourcePathMetaCollection.put("name", name);
|
||||||
|
@ -839,7 +839,7 @@ public class MongoIOManager {
|
||||||
* @param isLock
|
* @param isLock
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected String readByInputStream(MyFile resource, GridFSDBFile f, boolean isLock, int count) {
|
protected String readByInputStream(RequestObject resource, GridFSDBFile f, boolean isLock, int count) {
|
||||||
String key=null;
|
String key=null;
|
||||||
resource.setInputStream(new MongoInputStream(mongo, f.getInputStream()));
|
resource.setInputStream(new MongoInputStream(mongo, f.getInputStream()));
|
||||||
return key;
|
return key;
|
||||||
|
@ -852,7 +852,7 @@ public class MongoIOManager {
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected String readByOutputStream(MyFile resource, GridFSDBFile f, boolean isLock, int count)
|
protected String readByOutputStream(RequestObject resource, GridFSDBFile f, boolean isLock, int count)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String key=null;
|
String key=null;
|
||||||
f.writeTo(resource.getOutputStream());
|
f.writeTo(resource.getOutputStream());
|
||||||
|
@ -870,7 +870,7 @@ public class MongoIOManager {
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected String readByPath(MyFile resource, GridFSDBFile f, boolean isLock, int count)
|
protected String readByPath(RequestObject resource, GridFSDBFile f, boolean isLock, int count)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String key=null;
|
String key=null;
|
||||||
try{
|
try{
|
||||||
|
|
|
@ -14,11 +14,10 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.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;
|
||||||
|
@ -151,7 +150,7 @@ public class MongoOperationManager extends TransportManager{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, StorageObject> getValues(MyFile resource, String bucket, Class<? extends Object> type){
|
public Map<String, StorageObject> getValues(RequestObject resource, String bucket, Class<? extends Object> type){
|
||||||
Map<String, StorageObject> map=null;
|
Map<String, StorageObject> map=null;
|
||||||
try{
|
try{
|
||||||
OperationDefinition op=resource.getOperationDefinition();
|
OperationDefinition op=resource.getOperationDefinition();
|
||||||
|
@ -224,7 +223,7 @@ public class MongoOperationManager extends TransportManager{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRemoteFile(String bucket, MyFile resource) throws UnknownHostException{
|
public void removeRemoteFile(String bucket, RequestObject resource) throws UnknownHostException{
|
||||||
logger.info("Check file: "+bucket+ " for removing operation");
|
logger.info("Check file: "+bucket+ " for removing operation");
|
||||||
GridFSDBFile f=mongoPrimaryInstance.retrieveRemoteDescriptor(bucket, null, true);
|
GridFSDBFile f=mongoPrimaryInstance.retrieveRemoteDescriptor(bucket, null, true);
|
||||||
if(f!=null){
|
if(f!=null){
|
||||||
|
@ -247,7 +246,7 @@ public class MongoOperationManager extends TransportManager{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDir(String remoteDir, MyFile resource){
|
public void removeDir(String remoteDir, RequestObject resource){
|
||||||
ArrayList<String> dirs=new ArrayList<String>();
|
ArrayList<String> dirs=new ArrayList<String>();
|
||||||
dirs.add(remoteDir);
|
dirs.add(remoteDir);
|
||||||
// patch for incompatibility v 1-2
|
// patch for incompatibility v 1-2
|
||||||
|
@ -300,7 +299,7 @@ public class MongoOperationManager extends TransportManager{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSize(String remotePath, MyFile file){
|
public long getSize(String remotePath, RequestObject file){
|
||||||
long length=-1;
|
long length=-1;
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
logger.debug("MongoDB - get Size for pathServer: "+remotePath);
|
logger.debug("MongoDB - get Size for pathServer: "+remotePath);
|
||||||
|
@ -346,9 +345,9 @@ public class MongoOperationManager extends TransportManager{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long renewTTL(MyFile resource) throws UnknownHostException, IllegalAccessException{
|
public long renewTTL(RequestObject resource) throws UnknownHostException, IllegalAccessException{
|
||||||
long ttl=-1;
|
long ttl=-1;
|
||||||
MyFile file=(MyFile)resource;
|
RequestObject file=(RequestObject)resource;
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=file.getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=file.getOperation().getRemoteResource();
|
||||||
String key=file.getLockedKey();
|
String key=file.getLockedKey();
|
||||||
String remotePath=file.getRemotePath();
|
String remotePath=file.getRemotePath();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.CopyDir;
|
import org.gcube.contentmanagement.blobstorage.service.operation.CopyDir;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
||||||
|
@ -51,7 +51,7 @@ public class CopyDirOperator extends CopyDir {
|
||||||
* @see org.gcube.contentmanagement.blobstorage.service.operation.CopyDir#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.resource.MyFile, java.lang.String, java.lang.String)
|
* @see org.gcube.contentmanagement.blobstorage.service.operation.CopyDir#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.resource.MyFile, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath)
|
public List<String> execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath)
|
||||||
throws UnknownHostException {
|
throws UnknownHostException {
|
||||||
String source=sourcePath;
|
String source=sourcePath;
|
||||||
source = appendFileSeparator(source);
|
source = appendFileSeparator(source);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.io.InputStream;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Copy;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Copy;
|
||||||
|
@ -47,13 +47,13 @@ public class CopyOperator extends Copy {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
// public String execute(MongoIO mongoPrimaryInstance) throws UnknownHostException {
|
// public String execute(MongoIO mongoPrimaryInstance) throws UnknownHostException {
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
public String execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
||||||
String source=sourcePath;
|
String source=sourcePath;
|
||||||
String destination=destinationPath;
|
String destination=destinationPath;
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String originalDir=((MyFile)resource).getLocalDir();
|
String originalDir=((RequestObject)resource).getLocalDir();
|
||||||
logger.debug("from directory: "+originalDir+ "to directory: "+dir);
|
logger.debug("from directory: "+originalDir+ "to directory: "+dir);
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
||||||
ObjectId destinationId=null;
|
ObjectId destinationId=null;
|
||||||
logger.debug("copy operation on Mongo backend, parameters: source path: "+source+" destination path: "+destination);
|
logger.debug("copy operation on Mongo backend, parameters: source path: "+source+" destination path: "+destination);
|
||||||
|
@ -96,11 +96,11 @@ public class CopyOperator extends Copy {
|
||||||
|
|
||||||
|
|
||||||
public String safePut(MongoIOManager mongoPrimaryInstance, Object resource, String bucket, String key, boolean replace) throws UnknownHostException{
|
public String safePut(MongoIOManager mongoPrimaryInstance, Object resource, String bucket, String key, boolean replace) throws UnknownHostException{
|
||||||
OperationDefinition op=((MyFile)resource).getOperationDefinition();
|
OperationDefinition op=((RequestObject)resource).getOperationDefinition();
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=((MyFile)resource).getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=((RequestObject)resource).getOperation().getRemoteResource();
|
||||||
logger.info("MongoClient put method: "+op.toString());
|
logger.info("MongoClient put method: "+op.toString());
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
ObjectId id=null;
|
ObjectId id=null;
|
||||||
ObjectId oldId=null;
|
ObjectId oldId=null;
|
||||||
// id of the remote file if present
|
// id of the remote file if present
|
||||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.DuplicateFile;
|
import org.gcube.contentmanagement.blobstorage.service.operation.DuplicateFile;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
||||||
|
@ -46,8 +46,8 @@ public class DuplicateOperator extends DuplicateFile {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance){
|
public String execute(MongoIOManager mongoPrimaryInstance){
|
||||||
String destination=((MyFile)getResource()).getRemotePath()+Costants.DUPLICATE_SUFFIX;
|
String destination=((RequestObject)getResource()).getRemotePath()+Costants.DUPLICATE_SUFFIX;
|
||||||
String dir=((MyFile)getResource()).getRemoteDir();
|
String dir=((RequestObject)getResource()).getRemoteDir();
|
||||||
// String name=((MyFile)getResource()).getName();
|
// String name=((MyFile)getResource()).getName();
|
||||||
if((getBucket() != null) && (!getBucket().isEmpty())){
|
if((getBucket() != null) && (!getBucket().isEmpty())){
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Link;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Link;
|
||||||
|
@ -48,7 +48,7 @@ public class LinkOperator extends Link {
|
||||||
* @see org.gcube.contentmanagement.blobstorage.service.operation.Link#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.resource.MyFile, java.lang.String)
|
* @see org.gcube.contentmanagement.blobstorage.service.operation.Link#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.resource.MyFile, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
||||||
boolean replace=true;
|
boolean replace=true;
|
||||||
String source=sourcePath;
|
String source=sourcePath;
|
||||||
String destination=destinationPath;
|
String destination=destinationPath;
|
||||||
|
@ -81,7 +81,7 @@ public class LinkOperator extends Link {
|
||||||
String oldir=(String)fold.get("dir");
|
String oldir=(String)fold.get("dir");
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
logger.debug("old dir found "+oldir);
|
logger.debug("old dir found "+oldir);
|
||||||
if((oldir.equalsIgnoreCase(((MyFile)resource).getRemoteDir()))){
|
if((oldir.equalsIgnoreCase(((RequestObject)resource).getRemoteDir()))){
|
||||||
ObjectId oldId=(ObjectId) fold.getId();
|
ObjectId oldId=(ObjectId) fold.getId();
|
||||||
if(!replace){
|
if(!replace){
|
||||||
return oldId.toString();
|
return oldId.toString();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
|
package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
|
@ -45,7 +45,7 @@ public class LockOperator extends Lock {
|
||||||
* @see org.gcube.contentmanagement.blobstorage.service.operation.Lock#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO)
|
* @see org.gcube.contentmanagement.blobstorage.service.operation.Lock#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String serverLocation) throws Exception {
|
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String serverLocation) throws Exception {
|
||||||
OperationDefinition op=resource.getOperationDefinition();
|
OperationDefinition op=resource.getOperationDefinition();
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
||||||
// if((resource.getLocalPath()!= null) && (!resource.getLocalPath().isEmpty())){
|
// if((resource.getLocalPath()!= null) && (!resource.getLocalPath().isEmpty())){
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.MoveDir;
|
import org.gcube.contentmanagement.blobstorage.service.operation.MoveDir;
|
||||||
|
@ -52,8 +52,8 @@ public class MoveDirOperator extends MoveDir {
|
||||||
* @see org.gcube.contentmanagement.blobstorage.service.operation.MoveDir#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.resource.MyFile, java.lang.String, java.lang.String)
|
* @see org.gcube.contentmanagement.blobstorage.service.operation.MoveDir#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.resource.MyFile, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath,
|
public List<String> execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath,
|
||||||
String destinationPath, MemoryType memoryType) throws UnknownHostException {
|
String destinationPath, MemoryType memoryType) throws UnknownHostException {
|
||||||
String source=sourcePath;
|
String source=sourcePath;
|
||||||
source = appendFileSeparator(source);
|
source = appendFileSeparator(source);
|
||||||
String parentFolder=extractParent(source);
|
String parentFolder=extractParent(source);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Move;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Move;
|
||||||
|
@ -53,12 +53,12 @@ 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 {
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
public String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException {
|
||||||
String source=sourcePath;
|
String source=sourcePath;
|
||||||
String destination=destinationPath;
|
String destination=destinationPath;
|
||||||
resource.setLocalPath(sourcePath);
|
resource.setLocalPath(sourcePath);
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
String destinationId=null;
|
String destinationId=null;
|
||||||
String sourceId=null;
|
String sourceId=null;
|
||||||
logger.info("move operation on Mongo backend, parameters: source path: "+source+" destination path: "+destination);
|
logger.info("move operation on Mongo backend, parameters: source path: "+source+" destination path: "+destination);
|
||||||
|
@ -111,7 +111,7 @@ public class MoveOperator extends Move {
|
||||||
// update fields
|
// update fields
|
||||||
mongoPrimaryInstance.buildDirTree(mongoPrimaryInstance.getMetaDataCollection(mongoPrimaryInstance.getConnectionDB( MongoOperationManager.getPrimaryCollectionName(), true)), dir);
|
mongoPrimaryInstance.buildDirTree(mongoPrimaryInstance.getMetaDataCollection(mongoPrimaryInstance.getConnectionDB( MongoOperationManager.getPrimaryCollectionName(), true)), dir);
|
||||||
sourcePathMetaCollection= new BasicDBObject();
|
sourcePathMetaCollection= new BasicDBObject();
|
||||||
sourcePathMetaCollection.put("$set", new BasicDBObject().append("dir", dir).append("filename", destinationPath).append("name", name).append("owner", ((MyFile)resource).getOwner()));
|
sourcePathMetaCollection.put("$set", new BasicDBObject().append("dir", dir).append("filename", destinationPath).append("name", name).append("owner", ((RequestObject)resource).getOwner()));
|
||||||
logger.info("new object merged ");
|
logger.info("new object merged ");
|
||||||
mongoPrimaryInstance.printObject(sourcePathMetaCollection);
|
mongoPrimaryInstance.printObject(sourcePathMetaCollection);
|
||||||
//applies the update
|
//applies the update
|
||||||
|
@ -174,7 +174,7 @@ public class MoveOperator extends Move {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DBObject setCommonFields(DBObject sourcePathMetaCollection, MyFile resource, OPERATION op) {
|
private DBObject setCommonFields(DBObject sourcePathMetaCollection, RequestObject resource, OPERATION op) {
|
||||||
String owner=resource.getOwner();
|
String owner=resource.getOwner();
|
||||||
if(op == null){
|
if(op == null){
|
||||||
op=resource.getOperationDefinition().getOperation();
|
op=resource.getOperationDefinition().getOperation();
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCAL_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
|
@ -38,7 +38,7 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
Logger logger=LoggerFactory.getLogger(SoftCopyOperator.class);
|
Logger logger=LoggerFactory.getLogger(SoftCopyOperator.class);
|
||||||
private MemoryType memoryType;
|
private MemoryType memoryType;
|
||||||
private MongoIOManager mongoPrimaryInstance;
|
private MongoIOManager mongoPrimaryInstance;
|
||||||
private MyFile resource;
|
private RequestObject resource;
|
||||||
/**
|
/**
|
||||||
* @param server
|
* @param server
|
||||||
* @param user
|
* @param user
|
||||||
|
@ -56,7 +56,7 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath)
|
public String execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath)
|
||||||
throws UnknownHostException {
|
throws UnknownHostException {
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
||||||
LOCAL_RESOURCE localResourceIdentifier=resource.getOperation().getLocalResource();
|
LOCAL_RESOURCE localResourceIdentifier=resource.getOperation().getLocalResource();
|
||||||
|
@ -71,9 +71,9 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
else
|
else
|
||||||
destination=destinationPath;
|
destination=destinationPath;
|
||||||
if(resource!=null){
|
if(resource!=null){
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
setMemoryType(((MyFile)resource).getGcubeMemoryType());
|
setMemoryType(((RequestObject)resource).getGcubeMemoryType());
|
||||||
}
|
}
|
||||||
setMongoPrimaryInstance(mongoPrimaryInstance);
|
setMongoPrimaryInstance(mongoPrimaryInstance);
|
||||||
ObjectId mapId=null;
|
ObjectId mapId=null;
|
||||||
|
@ -162,7 +162,7 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
return destObject.getId().toString();
|
return destObject.getId().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fillGenericDestinationFields(MyFile resource, ObjectId souceId) {
|
private String fillGenericDestinationFields(RequestObject resource, ObjectId souceId) {
|
||||||
String destination;
|
String destination;
|
||||||
destination=resource.getRootPath()+souceId;
|
destination=resource.getRootPath()+souceId;
|
||||||
resource.setName(souceId.toString());
|
resource.setName(souceId.toString());
|
||||||
|
@ -182,17 +182,17 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
*/
|
*/
|
||||||
private ObjectId createNewDuplicatesMap(DBCollection metaCollectionInstance, Object resource, GridFSDBFile sourceObject, String bucket, ObjectId sourceId) throws UnknownHostException {
|
private ObjectId createNewDuplicatesMap(DBCollection metaCollectionInstance, Object resource, GridFSDBFile sourceObject, String bucket, ObjectId sourceId) throws UnknownHostException {
|
||||||
ObjectId id = null;
|
ObjectId id = null;
|
||||||
String dir= ((MyFile)resource).getRemoteDir();
|
String dir= ((RequestObject)resource).getRemoteDir();
|
||||||
// create new dir (is it really needed in case of map object?)
|
// create new dir (is it really needed in case of map object?)
|
||||||
if((dir !=null && !dir.isEmpty()) && (bucket !=null && !bucket.isEmpty())){
|
if((dir !=null && !dir.isEmpty()) && (bucket !=null && !bucket.isEmpty())){
|
||||||
getMongoPrimaryInstance().buildDirTree(getMongoPrimaryInstance().getMetaDataCollection(null), dir);
|
getMongoPrimaryInstance().buildDirTree(getMongoPrimaryInstance().getMetaDataCollection(null), dir);
|
||||||
}
|
}
|
||||||
// create new map object
|
// create new map object
|
||||||
id= createNewObjectMap(metaCollectionInstance, (MyFile)resource, sourceObject, sourceId);
|
id= createNewObjectMap(metaCollectionInstance, (RequestObject)resource, sourceObject, sourceId);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectId createNewObjectMap(DBCollection metaCollectionInstance, MyFile resource, GridFSDBFile source, ObjectId sourceId) throws UnknownHostException {
|
private ObjectId createNewObjectMap(DBCollection metaCollectionInstance, RequestObject resource, GridFSDBFile source, ObjectId sourceId) throws UnknownHostException {
|
||||||
String md5=source.getMD5();
|
String md5=source.getMD5();
|
||||||
// set type of object
|
// set type of object
|
||||||
DBObject document=new BasicDBObject("type", "map");
|
DBObject document=new BasicDBObject("type", "map");
|
||||||
|
@ -207,7 +207,7 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DBObject createNewLinkObject(MyFile resource, GridFSDBFile sourceObject, String destination, DBCollection metaCollectionInstance, String md5, ObjectId mapId, ObjectId newId){
|
private DBObject createNewLinkObject(RequestObject resource, GridFSDBFile sourceObject, String destination, DBCollection metaCollectionInstance, String md5, ObjectId mapId, ObjectId newId){
|
||||||
DBObject document=new BasicDBObject("type", "file");
|
DBObject document=new BasicDBObject("type", "file");
|
||||||
document.put("filename", destination);
|
document.put("filename", destination);
|
||||||
document.put("name", resource.getName());
|
document.put("name", resource.getName());
|
||||||
|
@ -227,8 +227,8 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
return fillCommonfields(document, resource, sourceObject, metaCollectionInstance, md5);
|
return fillCommonfields(document, resource, sourceObject, metaCollectionInstance, md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DBObject fillCommonfields(DBObject document, MyFile resource, GridFSDBFile sourceObject, DBCollection metaCollectionInstance, String md5) {
|
private DBObject fillCommonfields(DBObject document, RequestObject resource, GridFSDBFile sourceObject, DBCollection metaCollectionInstance, String md5) {
|
||||||
document.put("mimetype", ((MyFile)resource).getMimeType());
|
document.put("mimetype", ((RequestObject)resource).getMimeType());
|
||||||
document.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
document.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
|
||||||
document.put("md5", md5);
|
document.put("md5", md5);
|
||||||
document.put("length", sourceObject.getLength());
|
document.put("length", sourceObject.getLength());
|
||||||
|
@ -339,11 +339,11 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
this.mongoPrimaryInstance = mongoPrimaryInstance;
|
this.mongoPrimaryInstance = mongoPrimaryInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyFile getResource() {
|
public RequestObject getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(MyFile resource) {
|
public void setResource(RequestObject resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.resource.OperationDefinition.OPERATION;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.OPERATION;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
|
@ -45,7 +45,7 @@ public class UnlockOperator extends Unlock {
|
||||||
* @see org.gcube.contentmanagement.blobstorage.service.operation.Unlock#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO)
|
* @see org.gcube.contentmanagement.blobstorage.service.operation.Unlock#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String bucket, String key4unlock) throws Exception {
|
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String bucket, String key4unlock) throws Exception {
|
||||||
String id=null;
|
String id=null;
|
||||||
OperationDefinition op=resource.getOperationDefinition();
|
OperationDefinition op=resource.getOperationDefinition();
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
|
||||||
|
@ -58,8 +58,8 @@ public class UnlockOperator extends Unlock {
|
||||||
// mongoPrimaryInstance.close();
|
// mongoPrimaryInstance.close();
|
||||||
// resource.setOperation(op);
|
// resource.setOperation(op);
|
||||||
// }
|
// }
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
String path=getBucket();
|
String path=getBucket();
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
logger.debug("DIR: "+dir+" name: "+name+" fullPath "+path+" bucket: "+bucket);
|
logger.debug("DIR: "+dir+" name: "+name+" fullPath "+path+" bucket: "+bucket);
|
||||||
|
@ -68,7 +68,7 @@ public class UnlockOperator extends Unlock {
|
||||||
String oldir=(String)f.get("dir");
|
String oldir=(String)f.get("dir");
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
logger.debug("old dir found "+oldir);
|
logger.debug("old dir found "+oldir);
|
||||||
if((oldir.equalsIgnoreCase(((MyFile)resource).getRemoteDir())) || ((MyFile)resource).getRemoteDir()==null){
|
if((oldir.equalsIgnoreCase(((RequestObject)resource).getRemoteDir())) || ((RequestObject)resource).getRemoteDir()==null){
|
||||||
String lock=(String)f.get("lock");
|
String lock=(String)f.get("lock");
|
||||||
//check if the od file is locked
|
//check if the od file is locked
|
||||||
if((lock !=null) && (!lock.isEmpty())){
|
if((lock !=null) && (!lock.isEmpty())){
|
||||||
|
@ -76,14 +76,14 @@ public class UnlockOperator extends Unlock {
|
||||||
if(lck.equalsIgnoreCase(key4unlock)){
|
if(lck.equalsIgnoreCase(key4unlock)){
|
||||||
f.put("lock", null);
|
f.put("lock", null);
|
||||||
f.put("timestamp", null);
|
f.put("timestamp", null);
|
||||||
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (MyFile)resource, OPERATION.UNLOCK);
|
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (RequestObject)resource, OPERATION.UNLOCK);
|
||||||
f.save();
|
f.save();
|
||||||
}else{
|
}else{
|
||||||
mongoPrimaryInstance.close();
|
mongoPrimaryInstance.close();
|
||||||
throw new IllegalAccessError("bad key for unlock");
|
throw new IllegalAccessError("bad key for unlock");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (MyFile)resource, OPERATION.UNLOCK);
|
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (RequestObject)resource, OPERATION.UNLOCK);
|
||||||
f.save();
|
f.save();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
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.resource.OperationDefinition.REMOTE_RESOURCE;
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
||||||
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
|
||||||
|
@ -44,12 +44,12 @@ public class UploadOperator extends Upload {
|
||||||
* @see org.gcube.contentmanagement.blobstorage.service.operation.Upload#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO)
|
* @see org.gcube.contentmanagement.blobstorage.service.operation.Upload#execute(org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO, org.gcube.contentmanagement.blobstorage.transport.backend.MongoIO)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String bucket, boolean replace) throws IOException {
|
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String bucket, boolean replace) throws IOException {
|
||||||
OperationDefinition op=((MyFile)resource).getOperationDefinition();
|
OperationDefinition op=((RequestObject)resource).getOperationDefinition();
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=((MyFile)resource).getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=((RequestObject)resource).getOperation().getRemoteResource();
|
||||||
logger.info("MongoClient put method: "+op.toString());
|
logger.info("MongoClient put method: "+op.toString());
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
Object id=null;
|
Object id=null;
|
||||||
ObjectId oldId=null;
|
ObjectId oldId=null;
|
||||||
// id of the remote file if present
|
// id of the remote file if present
|
||||||
|
@ -79,11 +79,11 @@ public class UploadOperator extends Upload {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String executeSafeMode(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance) throws IOException {
|
public String executeSafeMode(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance) throws IOException {
|
||||||
OperationDefinition op=((MyFile)resource).getOperationDefinition();
|
OperationDefinition op=((RequestObject)resource).getOperationDefinition();
|
||||||
REMOTE_RESOURCE remoteResourceIdentifier=((MyFile)resource).getOperation().getRemoteResource();
|
REMOTE_RESOURCE remoteResourceIdentifier=((RequestObject)resource).getOperation().getRemoteResource();
|
||||||
logger.info("MongoClient put method: "+op.toString());
|
logger.info("MongoClient put method: "+op.toString());
|
||||||
String dir=((MyFile)resource).getRemoteDir();
|
String dir=((RequestObject)resource).getRemoteDir();
|
||||||
String name=((MyFile)resource).getName();
|
String name=((RequestObject)resource).getName();
|
||||||
ObjectId id=null;
|
ObjectId id=null;
|
||||||
ObjectId oldId=null;
|
ObjectId oldId=null;
|
||||||
// id of the remote file if present
|
// id of the remote file if present
|
||||||
|
|
Loading…
Reference in New Issue