update to gcube-bom 3.0.0-SNAPSHOT. Refactoring of RequestObject class

This commit is contained in:
Roberto Cirillo 2022-07-26 16:52:49 +02:00
parent 7837184e4b
commit bbfabd37d9
68 changed files with 553 additions and 555 deletions

View File

@ -23,7 +23,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.1</version>
<version>3.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@ -16,7 +16,7 @@ package org.gcube.contentmanagement.blobstorage.resource;
*
* It means that the client would be upload a file that have an absolute local path defined in pathClient field,
* on the remote location identifies by pathServer field of the resource MyFile
* @see org.gcube.contentmanagement.blobstorage.resource.MyFile
* @see RequestObject
*
* @author Roberto Cirillo (ISTI-CNR)
*

View File

@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
* @author Roberto Cirillo (ISTI - CNR)
*
*/
public class MyFile {
public class RequestObject {
// file 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);
}
@ -108,7 +108,7 @@ public class MyFile {
* @param name name 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.setName(name);
this.setLocalPath(pathClient);
@ -123,7 +123,7 @@ public class MyFile {
* @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.setName(name);
this.setLocalPath(pathClient);
@ -131,7 +131,7 @@ public class MyFile {
setGcubeMemoryType(memoryType);
}
public MyFile(MemoryType memoryType) {
public RequestObject(MemoryType memoryType) {
setGcubeMemoryType(memoryType);
}
@ -140,7 +140,7 @@ public class MyFile {
* build a new object with only the name setted
* @param name file name
*/
public MyFile(String name, MemoryType memoryType){
public RequestObject(String name, MemoryType memoryType){
setName(name);
setGcubeMemoryType(memoryType);
}
@ -245,8 +245,8 @@ public class MyFile {
* returns a copy of the current resource
* @return the file copy
*/
public MyFile copyProperties(){
MyFile dest=new MyFile(getGcubeMemoryType());
public RequestObject copyProperties(){
RequestObject dest=new RequestObject(getGcubeMemoryType());
dest.setOwner(getOwner());
dest.setLocalDir(this.getLocalDir());
dest.setRemoteDir(this.getRemoteDir());

View File

@ -5,7 +5,7 @@ import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.Map;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
@ -92,12 +92,12 @@ public class DirectoryBucket {
* @param bucket remote file to remove
*/
@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())
logger.debug("CHECK REMOVE: "+bucket);
String[] bucketList=null;
bucketList=retrieveBucketsName(path, rootArea);
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password, null, null);
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
tm=tmf.getTransport(tm, backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
// TerrastoreClient client=new TerrastoreClient( new OrderedHostManager(Arrays.asList(server)), new HTTPConnectionFactory());
for(int i=0;i<bucketList.length;i++){
@ -121,7 +121,7 @@ public class DirectoryBucket {
* remove a remote directory and all the files that the remote directory contains
* @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())
logger.debug("CHECK REMOVE: "+bucket);
String[] bucketList=null;
@ -130,7 +130,7 @@ public class DirectoryBucket {
if(logger.isDebugEnabled())
logger.debug("bucketDir Coded: "+bucketDirCoded);
bucketList=retrieveBucketsName(bucket, rootArea);
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password, region, token);
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
tm=tmf.getTransport(tm, backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(),resource.getReadPreference());
for(int i=0;i<bucketList.length;i++){
if(logger.isDebugEnabled())
@ -211,8 +211,8 @@ public class DirectoryBucket {
* @param bucketCoded bucketName coded
* @param tm a client for the cluster
*/
public String searchInBucket(MyFile resource, String name, String bucketCoded,
TransportManager tm, String rootArea) {
public String searchInBucket(RequestObject resource, String name, String bucketCoded,
TransportManager tm, String rootArea) {
Map <String, StorageObject> dirs=null;
try{
dirs=tm.getValues(resource, bucketCoded, DirectoryEntity.class);

View File

@ -1,6 +1,6 @@
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);
}
public DirectoryEntity(String dir, String author, MyFile file){
public DirectoryEntity(String dir, String author, RequestObject file){
setDirectory(dir);
setAuthor(author);
}

View File

@ -8,7 +8,7 @@ import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.DESedeKeySpec;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.encryption.encrypter.StringEncrypter;
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;

View File

@ -1,6 +1,6 @@
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;
/**
* 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 AmbiguousResource(MyFile file, ServiceEngine engine) {
public AmbiguousResource(RequestObject file, ServiceEngine engine) {
super(file, engine);
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.impl;
import java.io.InputStream;
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.REMOTE_RESOURCE;
@ -17,7 +17,7 @@ import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMO
public class LocalResource extends Resource{
public LocalResource(MyFile file, ServiceEngine engine) {
public LocalResource(RequestObject file, ServiceEngine engine) {
super(file, engine);
}
@ -46,7 +46,7 @@ public class LocalResource extends Resource{
if(getMyFile() != null){
getMyFile().setInputStream(is);
}else{
setMyFile(new MyFile(engine.getGcubeMemoryType()));
setMyFile(new RequestObject(engine.getGcubeMemoryType()));
getMyFile().setInputStream(is);
}
getMyFile().setLocalResource(LOCAL_RESOURCE.INPUT_STREAM);
@ -62,7 +62,7 @@ public class LocalResource extends Resource{
if(getMyFile() != null){
getMyFile().setOutputStream(os);
}else{
setMyFile(new MyFile(engine.getGcubeMemoryType()));
setMyFile(new RequestObject(engine.getGcubeMemoryType()));
getMyFile().setOutputStream(os);
}
getMyFile().setLocalResource(LOCAL_RESOURCE.OUTPUT_STREAM);

View File

@ -4,7 +4,7 @@ import java.net.UnknownHostException;
import java.util.Collections;
import java.util.List;
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.DirectoryBucket;
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryEntity;
@ -28,7 +28,7 @@ public class RemoteResource extends Resource{
TransportManager tm;
public RemoteResource(MyFile file, ServiceEngine engine) {
public RemoteResource(RequestObject file, ServiceEngine engine) {
super(file, engine);
logger.info("file gCube parameter costructor: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
}
@ -110,7 +110,7 @@ public class RemoteResource extends Resource{
getMyFile().setOwner(engine.owner);
if(engine.getCurrentOperation().equalsIgnoreCase("showdir")){
dir = new BucketCoding().bucketDirCoding(dir, engine.getContext());
TransportManagerFactory tmf= new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword(), engine.getRegion(), engine.getToken());
TransportManagerFactory tmf= new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword());
tm=tmf.getTransport(tm, engine.getBackendType(), engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
Map<String, StorageObject> mapDirs=null;
try {
@ -131,7 +131,7 @@ public class RemoteResource extends Resource{
if(!Costants.CLIENT_TYPE.equalsIgnoreCase("mongo"))
dirBuc.removeDirBucket(getMyFile(), dir, engine.getContext(), engine.getBackendType(), engine.getDbNames());
else{
TransportManagerFactory tmf=new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword(), engine.getRegion(),engine.getToken());
TransportManagerFactory tmf=new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword());
tm=tmf.getTransport(tm, Costants.CLIENT_TYPE, engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
dir=new BucketCoding().bucketFileCoding(dir, engine.getContext());
try {

View File

@ -3,7 +3,7 @@
*/
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.transport.backend.RemoteBackendException;
@ -17,7 +17,7 @@ public class RemoteResourceBoolean extends Resource{
* @param file
* @param engine
*/
public RemoteResourceBoolean(MyFile file, ServiceEngine engine) {
public RemoteResourceBoolean(RequestObject file, ServiceEngine engine) {
super(file, engine);
logger.info("file gCube parameter costructor: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
}

View File

@ -1,6 +1,6 @@
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.transport.backend.RemoteBackendException;
@ -12,7 +12,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
public class RemoteResourceComplexInfo extends Resource{
public RemoteResourceComplexInfo(MyFile file, ServiceEngine engine) {
public RemoteResourceComplexInfo(RequestObject file, ServiceEngine engine) {
super(file, engine);
}
@ -23,7 +23,7 @@ public class RemoteResourceComplexInfo extends Resource{
* @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"));
getMyFile().setRemotePath(path);
getMyFile().setRemoteResource(REMOTE_RESOURCE.PATH);

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.impl;
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.transport.backend.RemoteBackendException;
@ -12,7 +12,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
*/
public class RemoteResourceDestination extends Resource{
public RemoteResourceDestination(MyFile file, ServiceEngine engine) {
public RemoteResourceDestination(RequestObject file, ServiceEngine engine) {
super(file, engine);
}

View File

@ -1,6 +1,6 @@
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.transport.backend.RemoteBackendException;
@ -18,7 +18,7 @@ public class RemoteResourceFolderInfo extends Resource {
private String gcubeAccessType;
private String gcubeMemoryType;
public RemoteResourceFolderInfo(MyFile file, ServiceEngine engine) {
public RemoteResourceFolderInfo(RequestObject file, ServiceEngine engine) {
super(file, engine);
}

View File

@ -1,6 +1,6 @@
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.transport.backend.RemoteBackendException;
@ -14,7 +14,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
public class RemoteResourceInfo extends Resource{
public RemoteResourceInfo(MyFile file, ServiceEngine engine) {
public RemoteResourceInfo(RequestObject file, ServiceEngine engine) {
super(file, engine);
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.impl;
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;
/**
@ -11,7 +11,7 @@ import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.LOCA
*/
public class RemoteResourceSource extends Resource {
public RemoteResourceSource(MyFile file, ServiceEngine engine) {
public RemoteResourceSource(RequestObject file, ServiceEngine engine) {
super(file, engine);
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.impl;
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.transport.backend.RemoteBackendException;
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
@ -19,11 +19,11 @@ public class Resource {
final Logger logger = LoggerFactory.getLogger(ServiceEngine.class);
protected static final String BACKEND_STRING_SEPARATOR="%";
protected MyFile file;
protected RequestObject file;
protected ServiceEngine engine;
public Resource(MyFile file, ServiceEngine engine){
public Resource(RequestObject file, ServiceEngine engine){
setMyFile(file);
setEngine(engine);
}
@ -36,11 +36,11 @@ public class Resource {
this.engine = engine;
}
protected MyFile getMyFile(){
protected RequestObject getMyFile(){
return file;
}
protected void setMyFile(MyFile f){
protected void setMyFile(RequestObject f){
if (f!=null)
file=f;
else
@ -56,11 +56,11 @@ public class Resource {
* @param type remote or local
* @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(ObjectId.isValid(path)){
if(file==null)
file= new MyFile(path, engine.getGcubeMemoryType());
file= new RequestObject(path, engine.getGcubeMemoryType());
String id = file.getId();
if((id != null) && (!id.isEmpty()))
file.setId2(path);
@ -75,7 +75,7 @@ public class Resource {
logger.debug("path(String) - name: " + name);
}
if(file == null){
file= new MyFile(name, engine.getGcubeMemoryType());
file= new RequestObject(name, engine.getGcubeMemoryType());
}else{
file.setName(name);
}
@ -107,7 +107,7 @@ public class Resource {
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;
try{
obj=retrieveRemoteObject(file, backend);
@ -122,7 +122,7 @@ public class Resource {
return obj;
}
protected Object retrieveRemoteObject(MyFile file, String[] backend) throws RemoteBackendException {
protected Object retrieveRemoteObject(RequestObject file, String[] backend) throws RemoteBackendException {
Object obj=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());

View File

@ -8,7 +8,7 @@ import java.util.Set;
import org.gcube.contentmanagement.blobstorage.resource.AccessType;
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.REMOTE_RESOURCE;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
@ -43,7 +43,7 @@ public class ServiceEngine implements IClient {
public String[] primaryBackend;
public String[] volatileBackend;
protected OperationManager service;
protected MyFile file;
protected RequestObject file;
protected String bucket;
protected String bucketID;
protected String author;
@ -412,7 +412,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource remove(String backendType){
backendType=setBackendType(backendType);
file=new MyFile(getGcubeMemoryType());
file=new RequestObject(getGcubeMemoryType());
file.setGcubeAccessType(this.getGcubeAccessType());
file.setGcubeScope(this.getGcubeScope());
file.setOwnerGcube(this.getOwnerGcube());
@ -426,11 +426,11 @@ public class ServiceEngine implements IClient {
}
public MyFile getMyFile() {
public RequestObject getMyFile() {
return file;
}
public void setMyFile(MyFile myFile) {
public void setMyFile(RequestObject myFile) {
this.file = myFile;
}
@ -457,7 +457,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource showDir(String backendType){
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGcubeAccessType(this.getGcubeAccessType());
file.setGcubeScope(this.getGcubeScope());
file.setOwnerGcube(this.getOwnerGcube());
@ -495,7 +495,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource removeDir(String backendType){
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGcubeAccessType(this.getGcubeAccessType());
file.setGcubeScope(this.getGcubeScope());
file.setOwnerGcube(this.getOwnerGcube());
@ -527,7 +527,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource getUrl(String backendType, boolean forceCreation){
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGcubeAccessType(this.getGcubeAccessType());
file.setGcubeScope(this.getGcubeScope());
file.setOwnerGcube(this.getOwnerGcube());
@ -562,7 +562,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource getHttpUrl(String backendType, boolean forceCreation){
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGcubeAccessType(this.getGcubeAccessType());
file.setGcubeScope(this.getGcubeScope());
file.setOwnerGcube(this.getOwnerGcube());
@ -599,7 +599,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource getHttpsUrl(String backendType, boolean forceCreation){
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGcubeAccessType(this.getGcubeAccessType());
file.setGcubeScope(this.getGcubeScope());
file.setOwnerGcube(this.getOwnerGcube());
@ -672,7 +672,7 @@ public class ServiceEngine implements IClient {
public AmbiguousResource lock(String backendType) {
backendType=setBackendType(backendType);
file = new MyFile(true);
file = new RequestObject(true);
setCurrentOperation("lock");
this.service=new OperationManager(primaryBackend, user, password, getCurrentOperation(), file, backendType, getDbNames(), getToken());
file=setOperationInfo(file, OPERATION.LOCK);
@ -688,7 +688,7 @@ public class ServiceEngine implements IClient {
@Override
public AmbiguousResource unlock(String key, String backendType) {
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setLockedKey(key);
// put(true);
setCurrentOperation("unlock");
@ -706,7 +706,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResourceInfo getTTL(String backendType) {
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
// put(true);
setCurrentOperation("getTTL");
file=setOperationInfo(file, OPERATION.GET_TTL);
@ -724,7 +724,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource getMetaInfo(String field, String backendType) {
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGenericPropertyField(field);
setCurrentOperation("getMetaInfo");
file=setOperationInfo(file, OPERATION.GET_META_INFO);
@ -740,7 +740,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResource setMetaInfo(String field, String value, String backendType) {
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setGenericPropertyField(field);
file.setGenericPropertyValue(value);
setCurrentOperation("setMetaInfo");
@ -757,7 +757,7 @@ public class ServiceEngine implements IClient {
@Override
public RemoteResourceInfo renewTTL(String key, String backendType) {
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setLockedKey(key);
// put(true);
setCurrentOperation("renewTTL");
@ -999,9 +999,9 @@ public class ServiceEngine implements IClient {
// this.gcubeMemoryType = gcubeMemoryType;
}
private MyFile setOperationInfo(MyFile file, OPERATION op) {
private RequestObject setOperationInfo(RequestObject file, OPERATION op) {
if(file==null)
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setOperation(op);
if(getWriteConcern() != null)
file.setWriteConcern(getWriteConcern());
@ -1014,9 +1014,9 @@ public class ServiceEngine implements IClient {
return file;
}
private MyFile setMimeType(MyFile file, String mime) {
private RequestObject setMimeType(RequestObject file, String mime) {
if(file==null)
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
file.setMimeType(mime);
return file;
}
@ -1095,7 +1095,7 @@ public class ServiceEngine implements IClient {
public RemoteResource getRemotePath(){
backendType=setBackendType(backendType);
file=new MyFile(this.getGcubeMemoryType());
file=new RequestObject(this.getGcubeMemoryType());
// put(true);
setCurrentOperation("getRemotePath");
file=setOperationInfo(file, OPERATION.GET_REMOTE_PATH);

View File

@ -1,6 +1,6 @@
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.TransportManagerFactory;
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.UploadOperator;
@ -29,7 +29,7 @@ public class ChunkConsumer implements Runnable {
boolean isChunk=false;
String[] dbNames;
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;
Thread producer;
@ -37,7 +37,7 @@ public class ChunkConsumer implements Runnable {
if (logger.isDebugEnabled()) {
logger.debug("run() - start");
}
MyFile request = null;
RequestObject request = null;
synchronized (ChunkConsumer.class) {
request=monitor.getRequest();
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()) {
logger.debug("connection(MyFile) - start");
}
@ -108,7 +108,7 @@ public class ChunkConsumer implements Runnable {
return server;
}
private void putInTerrastore(MyFile myFile) {
private void putInTerrastore(RequestObject requestObject) {
if (logger.isDebugEnabled()) {
logger.debug("putInTerrastore(MyFile) - start");
}
@ -117,8 +117,8 @@ public class ChunkConsumer implements Runnable {
start=System.currentTimeMillis();
synchronized(ChunkConsumer.class){
String [] randomServer=randomizeServer(server);
TransportManagerFactory tmf=new TransportManagerFactory(randomServer, null, null, null, null);
client.set(tmf.getTransport(null, Costants.CLIENT_TYPE, null, null, myFile.getWriteConcern(), myFile.getReadPreference()));
TransportManagerFactory tmf=new TransportManagerFactory(randomServer, null, null);
client.set(tmf.getTransport(null, Costants.CLIENT_TYPE, null, null, requestObject.getWriteConcern(), requestObject.getReadPreference()));
}
if(logger.isDebugEnabled()){
logger.debug("waiting time for upload: "

View File

@ -9,7 +9,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
*/
public class ChunkProducer implements Runnable{
MyFile resource;
RequestObject resource;
long dimensionChunk;
int totChunks;
int nThreads;
@ -31,8 +31,8 @@ public class ChunkProducer implements Runnable{
String bucketName;
final Logger logger=LoggerFactory.getLogger(ChunkProducer.class);
public ChunkProducer(Monitor monitor, MyFile resource, long dimensionChunk, int totChunks,
int nThreads, String bucket, ChunkConsumer consumer ) throws FileNotFoundException{
public ChunkProducer(Monitor monitor, RequestObject resource, long dimensionChunk, int totChunks,
int nThreads, String bucket, ChunkConsumer consumer ) throws FileNotFoundException{
this.resource=resource;
this.dimensionChunk=dimensionChunk;
this.totChunks=totChunks;
@ -77,7 +77,7 @@ public class ChunkProducer implements Runnable{
//---- creo i task e li invio al thread-pool ----
String key= getBucketName()+i;
resource.setKey(key);
MyFile copy=resource.copyProperties();
RequestObject copy=resource.copyProperties();
copy.setContent(chunk);
if(logger.isDebugEnabled()){
logger.debug("request in queue: "+key);

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
protected String sourcePath;
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) {
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.destinationPath=remotePath;
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
@ -36,8 +36,8 @@ public abstract class Copy extends Operation{
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String id=null;
try {
// id=tm.copy(myFile, sourcePath, destinationPath);
@ -52,8 +52,8 @@ public abstract class Copy extends Operation{
@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
this.sourcePath=resource.getLocalPath();
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(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath, String destinationPath) throws UnknownHostException;
public MyFile getResource() {
public abstract String execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath, String destinationPath) throws UnknownHostException;
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
import java.net.UnknownHostException;
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.transport.TransportManager;
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);
private String sourcePath;
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) {
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.destinationPath=remotePath;
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
@ -39,8 +39,8 @@ public abstract class CopyDir extends Operation{
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm = getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm = getTransport(requestObject);
List<String> ids=null;
try {
// ids=tm.copyDir(myFile, sourcePath, destinationPath);
@ -57,8 +57,8 @@ public abstract class CopyDir extends Operation{
@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) {
// DirectoryBucket dirBuc=new DirectoryBucket(server, user, password, remotePath, author);
// For terrastore, the name of bucket is formed: path_____fileName_____author
// String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
@ -70,7 +70,7 @@ public abstract class CopyDir extends Operation{
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() {
return sourcePath;
@ -88,11 +88,11 @@ public abstract class CopyDir extends Operation{
this.destinationPath = destinationPath;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
@ -26,35 +26,35 @@ public abstract class Download extends Operation{
protected String localPath;
protected String remotePath;
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) {
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.localPath=file.getLocalPath();
this.remotePath=remotePath;
setResource(file);
return getRemoteIdentifier(remotePath, rootArea);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
public String doIt(RequestObject requestObject) throws RemoteBackendException{
String id=null;
if (logger.isDebugEnabled()) {
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
+ " in bucket: " + getBucket());
}
try {
id=get(this, myFile, false);
id=get(this, requestObject, false);
} catch (Throwable e) {
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
tm.close();
logger.error("Problem in download from: "+myFile.getRemotePath()+": "+e.getMessage());
logger.error("Problem in download from: "+ requestObject.getRemotePath()+": "+e.getMessage());
// e.printStackTrace();
throw new RemoteBackendException(" Problem in download operation ", e.getCause());
}
@ -63,8 +63,8 @@ public abstract class Download extends Operation{
@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) {
// DirectoryBucket dirBuc=new DirectoryBucket(server, getUser(), getPassword(), remotePath, author);
// For terrastore, the name of bucket is formed: path_____fileName_____author
String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
@ -76,11 +76,11 @@ public abstract class Download extends Operation{
public abstract ObjectId execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance) throws IOException;
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.backend.RemoteBackendException;
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.DownloadOperator;
@ -29,17 +29,17 @@ public class DownloadAndLock extends Operation {
}
@Override
public String doIt(MyFile myFile) throws RemoteBackendException {
public String doIt(RequestObject requestObject) throws RemoteBackendException {
if (logger.isDebugEnabled()) {
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
+ " in bucket: " + getBucket());
}
Download download = new DownloadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
try {
//TODO add field for file lock
get(download,myFile, true);
get(download, requestObject, true);
} catch (Exception e) {
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
tm.close();
throw new RemoteBackendException(" Error in downloadAndLock operation ", e.getCause());
}
@ -47,17 +47,17 @@ public class DownloadAndLock extends Operation {
}
@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) {
this.localPath=file.getLocalPath();
this.remotePath=remotePath;
return getRemoteIdentifier(remotePath, rootArea);
}
@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) {
// TODO Auto-generated method stub
return null;
}

View File

@ -4,7 +4,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
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) {
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String id=null;
try {
// id = tm.duplicateFile(myFile, bucket);
@ -45,7 +45,7 @@ public abstract class DuplicateFile extends Operation {
}
@Override
public String initOperation(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){
boolean isId=ObjectId.isValid(remotePath);
setResource(file);
@ -64,8 +64,8 @@ public abstract class DuplicateFile extends Operation {
@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) {
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;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -3,7 +3,7 @@
*/
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.bson.types.ObjectId;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
boolean isPresent=false;
try {
isPresent = tm.exist(bucket);
@ -44,8 +44,8 @@ public class Exist extends Operation{
}
@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) {
// String[] dirs= remotePath.split(file_separator);
if(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
@ -61,8 +61,8 @@ public class Exist extends Operation{
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with Exist operation");
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
//import org.apache.log4j.Logger;
//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.LoggerFactory;
import java.io.IOException;
@ -31,7 +31,7 @@ public class FileWriter extends Thread{
if (logger.isDebugEnabled()) {
logger.debug("run() - start");
}
MyFile request = monitor.getRequest();
RequestObject request = monitor.getRequest();
synchronized (FileWriter.class) {
if(logger.isDebugEnabled()){
logger.debug("recover request: "+request.getKey()+" length: "+request.getContent().length);

View File

@ -1,6 +1,6 @@
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.backend.RemoteBackendException;
import org.slf4j.Logger;
@ -17,8 +17,8 @@ public class ForceClose extends Operation{
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
try {
tm.forceClose();
} catch (Exception e) {
@ -30,15 +30,15 @@ public class ForceClose extends Operation{
}
@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) {
return null;
}
@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) {
return null;
}

View File

@ -1,6 +1,6 @@
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.DirectoryBucket;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
long dim=0;
try {
dim = tm.getFolderTotalItems(bucket);
@ -35,8 +35,8 @@ public class GetFolderCount extends Operation {
}
@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(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
String buck=null;
@ -53,8 +53,8 @@ public class GetFolderCount extends Operation {
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -1,6 +1,6 @@
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.DirectoryBucket;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
public String doIt(RequestObject requestObject) throws RemoteBackendException{
return null;
}
@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) {
// String[] dirs= remotePath.split(file_separator);
if(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
@ -43,8 +43,8 @@ public class GetFolderLastUpdate extends Operation {
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -1,6 +1,6 @@
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.DirectoryBucket;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
long dim=0;
try {
dim = tm.getFolderTotalVolume(bucket);
@ -35,8 +35,8 @@ public class GetFolderSize extends Operation {
}
@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) {
// String[] dirs= remotePath.split(file_separator);
if(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
@ -55,8 +55,8 @@ public class GetFolderSize extends Operation {
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import java.net.URL;
import org.apache.commons.codec.binary.Base64;
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.EncryptionException;
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
@ -33,28 +33,28 @@ public class GetHttpUrl extends Operation {
}
@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) {
return getRemoteIdentifier(remotePath, rootArea);
}
@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) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object doIt(MyFile myFile) throws RemoteBackendException {
String resolverHost=myFile.getResolverHOst();
public Object doIt(RequestObject requestObject) throws RemoteBackendException {
String resolverHost= requestObject.getResolverHOst();
String urlBase="smp://"+resolverHost+Costants.URL_SEPARATOR;
String urlParam="";
try {
// String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
String id=getId(myFile);
String phrase=myFile.getPassPhrase();
String id=getId(requestObject);
String phrase= requestObject.getPassPhrase();
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
urlParam = new Encrypter("DES", phrase).encrypt(id);
// String urlEncoded=URLEncoder.encode(urlParam, "UTF-8");
@ -72,7 +72,7 @@ public class GetHttpUrl extends Operation {
e.printStackTrace();
}
logger.info("URL translated: "+httpUrl);
if(myFile.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
if(requestObject.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
return httpUrl.toString()+Costants.VOLATILE_URL_IDENTIFICATOR;
}
return httpUrl.toString();
@ -81,7 +81,7 @@ public class GetHttpUrl extends Operation {
@Deprecated
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
String id=null;
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, getRegion(), getToken());
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
try {
id = tm.getId(bucket, forceCreation);
@ -94,11 +94,11 @@ public class GetHttpUrl extends Operation {
return id;
}
private String getId(MyFile myFile){
private String getId(RequestObject requestObject){
String id=null;
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
try {
id = tm.getId(bucket, myFile.isForceCreation());
id = tm.getId(bucket, requestObject.isForceCreation());
} catch (Exception e) {
tm.close();
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }

View File

@ -5,7 +5,7 @@ import java.net.URL;
import org.apache.commons.codec.binary.Base64;
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.EncryptionException;
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
@ -29,28 +29,28 @@ public class GetHttpsUrl extends Operation {
}
@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) {
return getRemoteIdentifier(remotePath, rootArea);
}
@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) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object doIt(MyFile myFile) throws RemoteBackendException {
String resolverHost=myFile.getResolverHOst();
public Object doIt(RequestObject requestObject) throws RemoteBackendException {
String resolverHost= requestObject.getResolverHOst();
String urlBase="smp://"+resolverHost+Costants.URL_SEPARATOR;
String urlParam="";
try {
String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
String id=getId(requestObject.getAbsoluteRemotePath(), requestObject.isForceCreation(), requestObject.getGcubeMemoryType(), requestObject.getWriteConcern(), requestObject.getReadPreference());
// String id=getId(myFile);
String phrase=myFile.getPassPhrase();
String phrase= requestObject.getPassPhrase();
// urlParam =new StringEncrypter("DES", phrase).encrypt(id);
urlParam = new Encrypter("DES", phrase).encrypt(id);
// String urlEncoded=URLEncoder.encode(urlParam, "UTF-8");
@ -68,17 +68,17 @@ public class GetHttpsUrl extends Operation {
e.printStackTrace();
}
logger.info("URL translated: "+httpsUrl);
if(myFile.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
if(requestObject.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
return httpsUrl.toString()+Costants.VOLATILE_URL_IDENTIFICATOR;
}
return httpsUrl.toString();
}
private String getId(MyFile myFile){
private String getId(RequestObject requestObject){
String id=null;
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
try {
id = tm.getId(bucket, myFile.isForceCreation());
id = tm.getId(bucket, requestObject.isForceCreation());
} catch (Exception e) {
tm.close();
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }
@ -91,7 +91,7 @@ public class GetHttpsUrl extends Operation {
@Deprecated
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
String id=null;
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, getRegion(), getToken());
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
try {
id = tm.getId(bucket, forceCreation);

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@ -29,20 +29,20 @@ public class GetMetaFile extends Operation{
* size.
*
*/
public MyFile doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public RequestObject doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
long dim=0;
String id=null;
String mime=null;
try {
dim = tm.getSize(bucket, myFile);
dim = tm.getSize(bucket, requestObject);
id=tm.getId(bucket, false);
mime=tm.getFileProperty(bucket, "mimetype");
myFile.setOwner(tm.getFileProperty(bucket, "owner"));
requestObject.setOwner(tm.getFileProperty(bucket, "owner"));
if(tm.isValidId(bucket)){
myFile.setRemotePath(tm.getFileProperty(bucket, "filename"));
myFile.setAbsoluteRemotePath(tm.getFileProperty(bucket, "filename"));
myFile.setName(tm.getFileProperty(bucket, "name"));
requestObject.setRemotePath(tm.getFileProperty(bucket, "filename"));
requestObject.setAbsoluteRemotePath(tm.getFileProperty(bucket, "filename"));
requestObject.setName(tm.getFileProperty(bucket, "name"));
}
} catch (Exception e) {
tm.close();
@ -50,16 +50,16 @@ public class GetMetaFile extends Operation{
if (logger.isDebugEnabled()) {
logger.debug(" PATH " + bucket);
}
myFile.setSize(dim);
myFile.setId(id);
myFile.setMimeType(mime);
requestObject.setSize(dim);
requestObject.setId(id);
requestObject.setMimeType(mime);
return myFile;
return requestObject;
}
@Override
public String initOperation(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) {
// String[] dirs= remotePath.split(file_separator);
if(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
@ -75,8 +75,8 @@ public class GetMetaFile extends Operation{
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String value=null;
try {
value=tm.getFileProperty(bucket, myFile.getGenericPropertyField());
value=tm.getFileProperty(bucket, requestObject.getGenericPropertyField());
} catch (Exception e) {
tm.close();
throw new RemoteBackendException(" Error in GetMetaFile operation ", e.getCause()); }
@ -35,8 +35,8 @@ public class GetMetaInfo extends Operation {
}
@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) {
// String[] dirs= remotePath.split(file_separator);
if(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
@ -52,8 +52,8 @@ public class GetMetaInfo extends Operation {
@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) {
throw new IllegalArgumentException("method not compatible with getMetaInfo operation");
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.backend.RemoteBackendException;
import org.slf4j.Logger;
@ -19,8 +19,8 @@ public class GetRemotePath extends Operation{
super(server, user, pwd, bucket, monitor, isChunk, backendType,dbs);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String path=null;
try {
path = tm.getRemotePath(bucket);
@ -42,8 +42,8 @@ public class GetRemotePath extends Operation{
}
@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) {
rootPath=file.getRootPath();
logger.trace("rootArea is "+file.getRootPath()+ " absoluteremotepath is "+file.getAbsoluteRemotePath());
if(logger.isDebugEnabled())
@ -58,8 +58,8 @@ public class GetRemotePath extends Operation{
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
long dim=0;
try {
dim = tm.getSize(bucket, myFile);
dim = tm.getSize(bucket, requestObject);
} catch (Exception e) {
tm.close();
throw new RemoteBackendException(" Error in GetSize operation ", e.getCause()); }
@ -41,8 +41,8 @@ public class GetSize extends Operation{
}
@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(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
String buck=null;
@ -57,8 +57,8 @@ public class GetSize extends Operation{
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.backend.RemoteBackendException;
import org.slf4j.Logger;
@ -26,16 +26,16 @@ public class GetTTL extends Operation {
}
@Override
public String doIt(MyFile myFile) throws RemoteBackendException {
public String doIt(RequestObject requestObject) throws RemoteBackendException {
if (logger.isDebugEnabled()) {
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
+ " in bucket: " + bucket);
}
long currentTTL=-1;
TransportManager tm=null;
try {
//aggiungere field per il lock del file
tm=getTransport(myFile);
tm=getTransport(requestObject);
currentTTL=tm.getTTL(bucket);
} catch (Exception e) {
tm.close();
@ -45,9 +45,9 @@ public class GetTTL extends Operation {
}
@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) {
this.localPath=file.getLocalPath();
this.remotePath=remotePath;
return getRemoteIdentifier(remotePath, rootArea);
@ -57,8 +57,8 @@ public class GetTTL extends Operation {
@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) {
// TODO Auto-generated method stub
return null;
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.EncryptionException;
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
@ -25,35 +25,35 @@ public class GetUrl extends Operation{
}
@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) {
return getRemoteIdentifier(remotePath, rootArea);
}
@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) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object doIt(MyFile myFile) throws RemoteBackendException {
String resolverHost=myFile.getResolverHOst();
public Object doIt(RequestObject requestObject) throws RemoteBackendException {
String resolverHost= requestObject.getResolverHOst();
String urlBase="smp://"+resolverHost+Costants.URL_SEPARATOR;
String urlParam="";
try {
// String id=getId(myFile.getAbsoluteRemotePath(), myFile.isForceCreation(), myFile.getGcubeMemoryType(), myFile.getWriteConcern(), myFile.getReadPreference());
String id=getId(myFile);
String phrase=myFile.getPassPhrase();
String id=getId(requestObject);
String phrase= requestObject.getPassPhrase();
urlParam = new Encrypter("DES", phrase).encrypt(id);
} catch (EncryptionException e) {
throw new RemoteBackendException(" Error in getUrl operation problem to encrypt the string", e.getCause());
}
String url=urlBase+urlParam;
logger.info("URL generated: "+url);
if(myFile.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
if(requestObject.getGcubeMemoryType().equals(MemoryType.VOLATILE)){
return url.toString()+Costants.VOLATILE_URL_IDENTIFICATOR;
}
return url;
@ -62,7 +62,7 @@ public class GetUrl extends Operation{
@Deprecated
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
String id=null;
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, getRegion(), getToken());
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
try {
id = tm.getId(bucket, forceCreation);
@ -75,11 +75,11 @@ public class GetUrl extends Operation{
return id;
}
private String getId(MyFile myFile){
private String getId(RequestObject requestObject){
String id=null;
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
try {
id = tm.getId(bucket, myFile.isForceCreation());
id = tm.getId(bucket, requestObject.isForceCreation());
} catch (Exception e) {
tm.close();
throw new RemoteBackendException(" Error in GetUrl operation. Problem to discover remote file:"+bucket+" "+ e.getMessage(), e.getCause()); }

View File

@ -1,6 +1,6 @@
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.DirectoryBucket;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String dim=null;
logger.info("check user total items for user: "+getOwner()+ " user is "+user);
try {
@ -35,8 +35,8 @@ public class GetUserTotalItems extends Operation {
}
@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) {
setOwner(author);
if((remotePath != null) && (remotePath.length() > 0)){
// String[] dirs= remotePath.split(file_separator);
@ -61,8 +61,8 @@ public class GetUserTotalItems extends Operation {
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -1,6 +1,6 @@
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.DirectoryBucket;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String dim=null;
logger.info("check user total volume for user: "+getOwner()+ " user is "+user);
try {
@ -34,8 +34,8 @@ public class GetUserTotalVolume extends Operation {
}
@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) {
setOwner(author);
if(remotePath!= null && remotePath.length()>0){
// String[] dirs= remotePath.split(file_separator);
@ -59,8 +59,8 @@ public class GetUserTotalVolume extends Operation {
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
private String sourcePath;
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) {
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.destinationPath=remotePath;
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
@ -35,8 +35,8 @@ public abstract class Link extends Operation{
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String id=null;
try {
id=tm.link(this);
@ -50,8 +50,8 @@ public abstract class Link extends Operation{
@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
// String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
this.sourcePath=resource.getLocalPath();
@ -62,7 +62,7 @@ public abstract class Link extends Operation{
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() {
return sourcePath;
@ -80,11 +80,11 @@ public abstract class Link extends Operation{
this.destinationPath = destinationPath;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -2,10 +2,9 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanagement.blobstorage.transport.backend.operation.DownloadOperator;
@ -24,7 +23,7 @@ public abstract class Lock extends Operation {
protected String localPath;
protected String remotePath;
protected OutputStream os;
protected MyFile resource;
protected RequestObject resource;
protected Download download;
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
public String doIt(MyFile myFile) throws RemoteBackendException {
public String doIt(RequestObject requestObject) throws RemoteBackendException {
if (logger.isDebugEnabled()) {
logger.debug(" DOWNLOAD " + myFile.getRemotePath()
logger.debug(" DOWNLOAD " + requestObject.getRemotePath()
+ " in bucket: " + getBucket());
}
String unlockKey=null;
try {
//aggiungere field per il lock del file
Download download = new DownloadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
unlockKey=get(download, myFile, true);
unlockKey=get(download, requestObject, true);
} catch (Exception e) {
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
tm.close();
throw new RemoteBackendException(" Error in lock operation ", e.getCause());
}
@ -52,9 +51,9 @@ public abstract class Lock extends Operation {
}
@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) {
String bucketName=null;
setResource(file);
// create the directory bucket
@ -71,13 +70,13 @@ public abstract class Lock extends Operation {
}
@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) {
// TODO Auto-generated method stub
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() {
return localPath;
@ -103,11 +102,11 @@ public abstract class Lock extends Operation {
this.os = os;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
//import org.apache.log4j.Logger;
//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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,9 +22,9 @@ public class Monitor {
// private static final GCUBELog logger = new GCUBELog(Monitor.class);
final Logger logger=LoggerFactory.getLogger(Monitor.class);
// request queue
private Vector<MyFile> requestQueue = new Vector<MyFile>();
private Vector<RequestObject> requestQueue = new Vector<RequestObject>();
// fetch the first request in the queue
public synchronized MyFile getRequest(){
public synchronized RequestObject getRequest(){
if (logger.isDebugEnabled()) {
logger.debug("getRequest() - start");
}
@ -36,15 +36,15 @@ public class Monitor {
logger.error("getRequest()", e);
}
}
MyFile myFile=requestQueue.remove(0);
RequestObject requestObject =requestQueue.remove(0);
notifyAll();
if (logger.isDebugEnabled()) {
logger.debug("getRequest() - end");
}
return myFile;
return requestObject;
}
public synchronized MyFile getRequest(ChunkProducer producer){
public synchronized RequestObject getRequest(ChunkProducer producer){
if (logger.isDebugEnabled()) {
logger.debug("getRequest(ChunkProducer) - start");
}
@ -56,16 +56,16 @@ public class Monitor {
logger.error("getRequest(ChunkProducer)", e);
}
}
MyFile myFile=requestQueue.remove(0);
RequestObject requestObject =requestQueue.remove(0);
notifyAll();
if (logger.isDebugEnabled()) {
logger.debug("getRequest(ChunkProducer) - end");
}
return myFile;
return requestObject;
}
// Accoda una nuova richiesta
public synchronized void putRequest(MyFile richiesta){
public synchronized void putRequest(RequestObject richiesta){
if (logger.isDebugEnabled()) {
logger.debug("putRequest(MyFile) - start");
logger.debug("request in queue, queue size: "+requestQueue.size());

View File

@ -3,7 +3,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
import java.net.UnknownHostException;
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.transport.TransportManager;
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);
protected String sourcePath;
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) {
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.destinationPath=remotePath;
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
@ -36,8 +36,8 @@ public abstract class Move extends Operation{
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String id=null;
try {
id=tm.move(this);
@ -51,8 +51,8 @@ public abstract class Move extends Operation{
@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) {
this.sourcePath=resource.getLocalPath();
this.destinationPath=resource.getRemotePath();
sourcePath = new BucketCoding().bucketFileCoding(resource.getLocalPath(), rootArea);
@ -61,7 +61,7 @@ public abstract class Move extends Operation{
return bucket=destinationPath;
}
public abstract String execute(MongoIOManager mongoPrimaryInstance, MemoryType memoryType, 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() {
return sourcePath;
@ -79,11 +79,11 @@ public abstract class Move extends Operation{
this.destinationPath = destinationPath;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -4,7 +4,7 @@ import java.net.UnknownHostException;
import java.util.List;
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.transport.TransportManager;
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);
private String sourcePath;
private String destinationPath;
private MyFile resource;
private RequestObject resource;
// private OutputStream os;
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);
}
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.destinationPath=remotePath;
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
@ -37,8 +37,8 @@ public abstract class MoveDir extends Operation{
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
List<String>ids=null;
try {
ids=tm.moveDir(this);
@ -52,8 +52,8 @@ public abstract class MoveDir extends Operation{
@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) {
this.sourcePath=resource.getLocalPath();
this.destinationPath=resource.getRemotePath();
sourcePath = new BucketCoding().bucketFileCoding(resource.getLocalPath(), rootArea);
@ -62,7 +62,7 @@ public abstract class MoveDir extends Operation{
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() {
return sourcePath;
@ -80,11 +80,11 @@ public abstract class MoveDir extends Operation{
this.destinationPath = destinationPath;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
@ -99,7 +99,7 @@ public abstract class Operation {
* @return a String that identifies a file
* @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()) {
logger.debug("put(MyFile, boolean, boolean) - start");
}
@ -169,23 +169,23 @@ public abstract class Operation {
/**
* Download operation
* @param myFile object that contains the resource coordinates
* @param requestObject object that contains the resource coordinates
* @throws IOException
* @throws InterruptedException
*/
public String get(Download download, MyFile myFile, boolean isLock) throws IOException, InterruptedException, Exception {
public String get(Download download, RequestObject requestObject, boolean isLock) throws IOException, InterruptedException, Exception {
if (logger.isDebugEnabled()) {
logger.debug("get(String) - start");
}
String unlocKey=null;
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
long start=System.currentTimeMillis();
String path=myFile.getLocalPath();
String path= requestObject.getLocalPath();
if(!Costants.CLIENT_TYPE.equalsIgnoreCase("mongo")){
startPThreadChunk(download, myFile, tm, path);
startPThreadChunk(download, requestObject, tm, path);
}else{
unlocKey=tm.downloadManager(download, myFile, bucket, MyFile.class);
unlocKey=tm.downloadManager(download, requestObject, bucket, RequestObject.class);
}
if((path!=null) && (new File(path).length()>0)){
@ -198,19 +198,19 @@ public abstract class Operation {
}
/**
* @param myFile
* @param requestObject
* @param tm
* @param path
* @throws FileNotFoundException
* @throws InterruptedException
* @throws IOException
*/
protected void startPThreadChunk(Download download,MyFile myFile, TransportManager tm,
String path) throws FileNotFoundException, InterruptedException,
protected void startPThreadChunk(Download download, RequestObject requestObject, TransportManager tm,
String path) throws FileNotFoundException, InterruptedException,
IOException {
ExecutorService executor = Executors.newFixedThreadPool (2);
int j=0;
MyFile value=null;
RequestObject value=null;
if(logger.isInfoEnabled())
logger.info("localPath: "+path+" bucket: "+bucket);
@ -224,7 +224,7 @@ public abstract class Operation {
logger.debug("get(String) -");
}
try{
value=(MyFile) tm.get(download);
value=(RequestObject) tm.get(download);
}catch(Exception e){
if (logger.isDebugEnabled()) {
logger.debug("get(String) - \n Trovate " + (j) + " key");
@ -274,11 +274,11 @@ public abstract class Operation {
/**
* Do a operation
* @param myFile object that contains the resource coordinates
* @param requestObject object that contains the resource coordinates
* @return a generic object that contains operation results
* @throws IllegalAccessException
*/
public abstract Object doIt(MyFile myFile) throws RemoteBackendException;
public abstract Object doIt(RequestObject requestObject) throws RemoteBackendException;
/**
* init a operation
@ -290,7 +290,7 @@ public abstract class Operation {
* @param replaceOption if true the file will be replaced
* @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
* @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() {
return owner;
@ -394,7 +394,7 @@ public abstract class Operation {
protected TransportManager getTransport(RequestObject myFile) {
// if(Objects.isNull(transport)) {
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password, region, token);
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
transport=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
// }
return transport;

View File

@ -1,6 +1,6 @@
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,7 +21,7 @@ public class OperationManager {
private String[] server;
// private int dimension;
private String operation;
private MyFile resource;
private RequestObject resource;
private boolean isChunk;
private String bucketName;
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.setUser(user);
this.setPassword(password);
this.setTypeOperation(operation);
this.setResource(myFile);
this.setResource(requestObject);
this.setTypeOperation(operation);
this.setDbNames(dbs);
this.backendType=backendType;
@ -124,11 +124,11 @@ public class OperationManager {
this.operation = operation;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -1,6 +1,6 @@
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.transport.TransportManager;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
removeBucket(tm, bucket, myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
removeBucket(tm, bucket, requestObject);
if (logger.isDebugEnabled()) {
logger.debug(" REMOVE " + bucket);
}
@ -33,8 +33,8 @@ public class Remove extends Operation{
}
@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) {
String[] dirs= remotePath.split(Costants.FILE_SEPARATOR);
if(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
@ -61,7 +61,7 @@ public class Remove extends Operation{
* @param bucketName indicates the remote directory to remove
* @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())
logger.debug("removing file bucket: "+bucketName);
try {
@ -74,8 +74,8 @@ public class Remove extends Operation{
}
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with remove operation");
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@ -28,12 +28,12 @@ public class RenewTTL extends Operation {
}
@Override
public String doIt(MyFile myFile) throws RemoteBackendException {
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException {
TransportManager tm=getTransport(requestObject);
long ttl=-1;
try {
myFile.setRemotePath(bucket);
ttl = tm.renewTTL(myFile);
requestObject.setRemotePath(bucket);
ttl = tm.renewTTL(requestObject);
} catch (Throwable e) {
tm.close();
throw new RemoteBackendException(" Error in renew TTL operation ", e.getCause());
@ -42,9 +42,9 @@ public class RenewTTL extends Operation {
}
@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) {
this.localPath=file.getLocalPath();
this.remotePath=remotePath;
String bucketName = new BucketCoding().bucketFileCoding(remotePath, rootArea);
@ -53,8 +53,8 @@ public class RenewTTL extends Operation {
}
@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) {
// TODO Auto-generated method stub
return null;
}

View File

@ -1,7 +1,7 @@
package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
try {
tm.setFileProperty(bucket, myFile.getGenericPropertyField(), myFile.getGenericPropertyValue());
tm.setFileProperty(bucket, requestObject.getGenericPropertyField(), requestObject.getGenericPropertyValue());
} catch (Exception e) {
tm.close();
e.printStackTrace();
@ -35,8 +35,8 @@ public class SetMetaInfo extends Operation {
}
@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(logger.isDebugEnabled())
logger.debug("remotePath: "+remotePath);
String buck=null;
@ -51,8 +51,8 @@ public class SetMetaInfo extends Operation {
@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) {
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
}

View File

@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
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);
private String sourcePath;
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) {
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.destinationPath=remotePath;
sourcePath = new BucketCoding().bucketFileCoding(file.getLocalPath(), rootArea);
@ -42,8 +42,8 @@ public abstract class SoftCopy extends Operation {
}
public String doIt(MyFile myFile) throws RemoteBackendException{
TransportManager tm=getTransport(myFile);
public String doIt(RequestObject requestObject) throws RemoteBackendException{
TransportManager tm=getTransport(requestObject);
String id=null;
try {
id=tm.softCopy(this);
@ -57,7 +57,7 @@ public abstract class SoftCopy extends Operation {
@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
this.sourcePath=resource.getLocalPath();
this.destinationPath=resource.getRemotePath();
@ -67,7 +67,7 @@ public abstract class SoftCopy extends Operation {
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() {
return sourcePath;
@ -85,11 +85,11 @@ public abstract class SoftCopy extends Operation {
this.destinationPath = destinationPath;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -2,7 +2,7 @@ package org.gcube.contentmanagement.blobstorage.service.operation;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
@ -22,7 +22,7 @@ public abstract class Unlock extends Operation {
protected String localPath;
protected String remotePath;
protected OutputStream os;
protected MyFile resource;
protected RequestObject resource;
protected Upload upload;
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
public String doIt(MyFile myFile) throws RemoteBackendException {
public String doIt(RequestObject requestObject) throws RemoteBackendException {
if (logger.isDebugEnabled()) {
logger.debug(" UPLOAD " + myFile.getLocalPath()
+ " author: " + myFile.getOwner());
logger.debug(" UPLOAD " + requestObject.getLocalPath()
+ " author: " + requestObject.getOwner());
}
String objectId=null;
try {
Upload upload= new UploadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
//inserire parametro per il lock
objectId=put(upload, myFile, isChunk(), false, false, true);
objectId=put(upload, requestObject, isChunk(), false, false, true);
} catch (Exception e) {
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
tm.close();
throw new RemoteBackendException(" Error in unlock operation ", e.getCause());
}
@ -51,9 +51,9 @@ public abstract class Unlock extends Operation {
}
@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) {
String bucketName=null;
// create the directory bucket
if((remotePath.length()<23) || (remotePath.contains(Costants.FILE_SEPARATOR))){
@ -68,13 +68,13 @@ public abstract class Unlock extends Operation {
}
@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) {
// TODO Auto-generated method stub
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() {
return localPath;
@ -100,11 +100,11 @@ public abstract class Unlock extends Operation {
this.os = os;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import java.io.InputStream;
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
@ -31,7 +31,7 @@ public abstract class Upload extends Operation {
protected String localPath;
protected String remotePath;
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) {
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()) {
logger.debug(" UPLOAD " + myFile.getLocalPath()
+ " author: " + myFile.getOwner());
logger.debug(" UPLOAD " + requestObject.getLocalPath()
+ " author: " + requestObject.getOwner());
}
String objectId=null;
try {
objectId=put(this, myFile, isChunk(), false, replaceOption, false);
objectId=put(this, requestObject, isChunk(), false, replaceOption, false);
} catch (Throwable e) {
e.printStackTrace();
TransportManager tm=getTransport(myFile);
TransportManager tm=getTransport(requestObject);
tm.close();
logger.error("Problem in upload from: "+myFile.getLocalPath()+": "+e.getMessage());
logger.error("Problem in upload from: "+ requestObject.getLocalPath()+": "+e.getMessage());
throw new RemoteBackendException(" Error in upload operation ", e.getCause());
}
return objectId;
@ -61,7 +61,7 @@ public abstract class Upload extends Operation {
@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
this.replaceOption=replaceOption;
setResource(file);
@ -78,8 +78,8 @@ public abstract class Upload extends Operation {
@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) {
// the name of bucket is formed: path_____fileName_____author
String bucketName=new BucketCoding().bucketFileCoding(remotePath, rootArea);
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() {
return is;
@ -150,13 +150,13 @@ public abstract class Upload extends Operation {
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -1,6 +1,6 @@
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.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
@ -21,19 +21,19 @@ public class UploadAndUnlock extends Operation {
}
@Override
public String doIt(MyFile myFile) throws RemoteBackendException {
public String doIt(RequestObject requestObject) throws RemoteBackendException {
if (logger.isDebugEnabled()) {
logger.debug(" UPLOAD " + myFile.getLocalPath()
+ " author: " + myFile.getOwner());
logger.debug(" UPLOAD " + requestObject.getLocalPath()
+ " author: " + requestObject.getOwner());
}
Upload upload= new UploadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
String objectId=null;
try {
//inserire parametro per il lock
objectId=put(upload, myFile, isChunk(), false, false, true);
objectId=put(upload, requestObject, isChunk(), false, false, true);
} catch (Exception e) {
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();
throw new RemoteBackendException(" Error in uploadAndUnlock operation ", e);
}
@ -42,9 +42,9 @@ public class UploadAndUnlock extends Operation {
}
@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
// this.replaceOption=replaceOption;
// the name of bucket is formed: path_____fileName_____author
@ -54,8 +54,8 @@ public class UploadAndUnlock extends Operation {
}
@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) {
// TODO Auto-generated method stub
return null;
}

View File

@ -7,7 +7,7 @@ import java.util.List;
import java.util.Map;
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.service.operation.*;
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
* @param myFile object that contains the resource coordinates
* @param requestObject object that contains the resource coordinates
* @param key remote path or objectId
* @param type class type of myFile object
* @return the key of remote resource
* @throws IOException if there are IO problems
*/
public String downloadManager(Download download, 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;
if(myFile.isLock()){
download.setResource(myFile);
if(requestObject.isLock()){
download.setResource(requestObject);
get(download);
Lock lock= new LockOperator(download.getServer(), download.getUser(), download.getPassword(), download.getBucket(), download.getMonitor(), download.isChunk(), download.getBackendType(), download.getDbNames());
lock.setResource(myFile);
lock.setResource(requestObject);
key4lock=lock(lock);
return key4lock;
}else{
@ -76,7 +76,7 @@ public abstract class TransportManager {
*/
public String uploadManager(Upload upload, Object resource, String bucket, String key, boolean replace) throws Exception{
String id=null;
MyFile file=(MyFile)resource;
RequestObject file=(RequestObject)resource;
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.setResource(file);
@ -133,34 +133,34 @@ public abstract class TransportManager {
* @return map that contains the object in the direcotry
* @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
* @param bucket identifies the remote file
* @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
* @param remoteDir remote Directory path
* @param myFile
* @param requestObject
* @throws IllegalStateException
* @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
* @param bucket identifies the remote file path
* @param myFile the file wrapper
* @param requestObject the file wrapper
* @return the size of the remote file
* @throws UnknownHostException
*/
public abstract long getSize(String bucket, MyFile myFile);
public abstract long getSize(String bucket, RequestObject requestObject);
/**
* lock a remote file
@ -210,7 +210,7 @@ public abstract class TransportManager {
* @throws UnknownHostException
* @throws IllegalAccessException
*/
public abstract long renewTTL(MyFile resource) throws UnknownHostException, IllegalAccessException;
public abstract long renewTTL(RequestObject resource) throws UnknownHostException, IllegalAccessException;
/**

View File

@ -36,7 +36,7 @@ public class TransportManagerFactory {
private String region;
TransportManager transport;
public TransportManagerFactory(String server[], String user, String password, String region, String token){
public TransportManagerFactory(String[] server, String user, String password){
this.server=server;
this.user=user;
this.password=password;

View File

@ -12,7 +12,7 @@ import java.util.List;
import java.util.Set;
import org.bson.types.ObjectId;
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.OPERATION;
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
@ -123,7 +123,7 @@ public class MongoIOManager {
return db;
}
//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;
id=(ObjectId)f.getId();
String lock=(String)f.get("lock");
@ -139,7 +139,7 @@ public class MongoIOManager {
return id;
}
public ObjectId getRemoteObject(MyFile resource, GridFSDBFile f) throws IOException, IllegalAccessError {
public ObjectId getRemoteObject(RequestObject resource, GridFSDBFile f) throws IOException, IllegalAccessError {
ObjectId id;
id=(ObjectId)f.getId();
String lock=(String)f.get("lock");
@ -185,7 +185,7 @@ public class MongoIOManager {
* @param isLock indicates if the file must be locked
* @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();
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
@ -216,7 +216,7 @@ public class MongoIOManager {
* @param isLock indicates if the file must be locked
* @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();
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
@ -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"));
String owner=resource.getOwner();
f.put("lastUser", owner);
@ -287,7 +287,7 @@ public class MongoIOManager {
close();
throw new IllegalAccessError("The file is locked");
}else{
oldId=checkAndRemove(fold, (MyFile)resource);
oldId=checkAndRemove(fold, (RequestObject)resource);
}
}
// }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();
logger.info("check and remove object with id "+idToRemove+" and path: "+f.get("filename"));
ObjectId idFile=null;
@ -408,12 +408,12 @@ public class MongoIOManager {
//maybe this close is not needed
// clean();
try{
if(((MyFile)resource).getInputStream()!= null){
if(((RequestObject)resource).getInputStream()!= null){
//upload with client inputStream
f2 = writeByInputStream(resource, bucket, name, dir,idFile);
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
f2 = writeByOutputStream(resource, bucket, name, dir, idFile);
}else{
@ -429,7 +429,7 @@ public class MongoIOManager {
logger.debug("ObjectId: "+id);
// 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();
}
}catch(IOException e1){
@ -454,9 +454,9 @@ public class MongoIOManager {
throws IOException {
GridFSInputFile f2;
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
f2 = createGFSFileObject(new File(((MyFile)resource).getLocalPath()));
f2 = createGFSFileObject(new File(((RequestObject)resource).getLocalPath()));
fillInputFile(resource, bucket, name, dir, f2, idFile);
saveGFSFileObject(f2);
return f2;
@ -466,11 +466,11 @@ public class MongoIOManager {
String bucket, String name, String dir, ObjectId idFile) throws IOException {
GridFSInputFile f2;
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
f2 = createGFSFileObject(((MyFile)resource).getName());
f2 = createGFSFileObject(((RequestObject)resource).getName());
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;
}
@ -479,13 +479,13 @@ public class MongoIOManager {
throws IOException {
GridFSInputFile f2;
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
f2 = createGFSFileObject(((MyFile)resource).getInputStream());
f2 = createGFSFileObject(((RequestObject)resource).getInputStream());
fillInputFile(resource, bucket, name, dir, f2, idFile);
saveGFSFileObject(f2);
((MyFile)resource).getInputStream().close();
((MyFile)resource).setInputStream(null);
((RequestObject)resource).getInputStream().close();
((RequestObject)resource).setInputStream(null);
return f2;
}
@ -503,14 +503,14 @@ public class MongoIOManager {
f2.put("name", name);
if(dir!=null)
f2.put("dir", dir);
if(((MyFile)resource).getOwner() !=null)
f2.put("owner", ((MyFile)resource).getOwner());
String mime= ((MyFile)resource).getMimeType();
if(((RequestObject)resource).getOwner() !=null)
f2.put("owner", ((RequestObject)resource).getOwner());
String mime= ((RequestObject)resource).getMimeType();
if( mime !=null){
f2.put("mimetype", mime);
}
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
* @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);
for(Iterator<GridFSDBFile> it=list.iterator(); it.hasNext();){
GridFSDBFile f=(GridFSDBFile)it.next();
@ -535,20 +535,20 @@ public class MongoIOManager {
}
public void setGenericProperties(MyFile resource, String destination,
String dir, GridFSInputFile destinationFile, String name) {
public void setGenericProperties(RequestObject resource, String destination,
String dir, GridFSInputFile destinationFile, String name) {
updateCommonFields(destinationFile, resource, null);
destinationFile.put("filename", destination);
destinationFile.put("type", "file");
destinationFile.put("name", name);
destinationFile.put("dir", dir);
destinationFile.put("owner", ((MyFile)resource).getOwner());
destinationFile.put("mimetype", ((MyFile)resource).getMimeType());
destinationFile.put("owner", ((RequestObject)resource).getOwner());
destinationFile.put("mimetype", ((RequestObject)resource).getMimeType());
destinationFile.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
}
public DBObject setGenericMoveProperties(MyFile resource, String filename, String dir,
String name, DBObject sourcePathMetaCollection) {
public DBObject setGenericMoveProperties(RequestObject resource, String filename, String dir,
String name, DBObject sourcePathMetaCollection) {
sourcePathMetaCollection.put("filename", filename);
sourcePathMetaCollection.put("type", "file");
sourcePathMetaCollection.put("name", name);
@ -839,7 +839,7 @@ public class MongoIOManager {
* @param isLock
* @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;
resource.setInputStream(new MongoInputStream(mongo, f.getInputStream()));
return key;
@ -852,7 +852,7 @@ public class MongoIOManager {
* @return
* @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 {
String key=null;
f.writeTo(resource.getOutputStream());
@ -870,7 +870,7 @@ public class MongoIOManager {
* @return
* @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 {
String key=null;
try{

View File

@ -14,11 +14,10 @@ import java.util.Map;
import java.util.Objects;
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.service.operation.*;
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoIOManager;
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
@ -151,7 +150,7 @@ public class MongoOperationManager extends TransportManager{
}
@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;
try{
OperationDefinition op=resource.getOperationDefinition();
@ -224,7 +223,7 @@ public class MongoOperationManager extends TransportManager{
@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");
GridFSDBFile f=mongoPrimaryInstance.retrieveRemoteDescriptor(bucket, null, true);
if(f!=null){
@ -247,7 +246,7 @@ public class MongoOperationManager extends TransportManager{
@Override
public void removeDir(String remoteDir, MyFile resource){
public void removeDir(String remoteDir, RequestObject resource){
ArrayList<String> dirs=new ArrayList<String>();
dirs.add(remoteDir);
// patch for incompatibility v 1-2
@ -300,7 +299,7 @@ public class MongoOperationManager extends TransportManager{
}
@Override
public long getSize(String remotePath, MyFile file){
public long getSize(String remotePath, RequestObject file){
long length=-1;
if(logger.isDebugEnabled())
logger.debug("MongoDB - get Size for pathServer: "+remotePath);
@ -346,9 +345,9 @@ public class MongoOperationManager extends TransportManager{
}
@Override
public long renewTTL(MyFile resource) throws UnknownHostException, IllegalAccessException{
public long renewTTL(RequestObject resource) throws UnknownHostException, IllegalAccessException{
long ttl=-1;
MyFile file=(MyFile)resource;
RequestObject file=(RequestObject)resource;
REMOTE_RESOURCE remoteResourceIdentifier=file.getOperation().getRemoteResource();
String key=file.getLockedKey();
String remotePath=file.getRemotePath();

View File

@ -8,7 +8,7 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
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.service.operation.CopyDir;
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)
*/
@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 {
String source=sourcePath;
source = appendFileSeparator(source);

View File

@ -7,7 +7,7 @@ import java.io.InputStream;
import java.net.UnknownHostException;
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.REMOTE_RESOURCE;
import org.gcube.contentmanagement.blobstorage.service.operation.Copy;
@ -47,13 +47,13 @@ public class CopyOperator extends Copy {
*/
@Override
// 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 destination=destinationPath;
String dir=((MyFile)resource).getRemoteDir();
String originalDir=((MyFile)resource).getLocalDir();
String dir=((RequestObject)resource).getRemoteDir();
String originalDir=((RequestObject)resource).getLocalDir();
logger.debug("from directory: "+originalDir+ "to directory: "+dir);
String name=((MyFile)resource).getName();
String name=((RequestObject)resource).getName();
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
ObjectId destinationId=null;
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{
OperationDefinition op=((MyFile)resource).getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=((MyFile)resource).getOperation().getRemoteResource();
OperationDefinition op=((RequestObject)resource).getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=((RequestObject)resource).getOperation().getRemoteResource();
logger.info("MongoClient put method: "+op.toString());
String dir=((MyFile)resource).getRemoteDir();
String name=((MyFile)resource).getName();
String dir=((RequestObject)resource).getRemoteDir();
String name=((RequestObject)resource).getName();
ObjectId id=null;
ObjectId oldId=null;
// id of the remote file if present

View File

@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
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.service.operation.DuplicateFile;
import org.gcube.contentmanagement.blobstorage.service.operation.Monitor;
@ -46,8 +46,8 @@ public class DuplicateOperator extends DuplicateFile {
*/
@Override
public String execute(MongoIOManager mongoPrimaryInstance){
String destination=((MyFile)getResource()).getRemotePath()+Costants.DUPLICATE_SUFFIX;
String dir=((MyFile)getResource()).getRemoteDir();
String destination=((RequestObject)getResource()).getRemotePath()+Costants.DUPLICATE_SUFFIX;
String dir=((RequestObject)getResource()).getRemoteDir();
// String name=((MyFile)getResource()).getName();
if((getBucket() != null) && (!getBucket().isEmpty())){
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();

View File

@ -7,7 +7,7 @@ import java.net.UnknownHostException;
import org.bson.types.ObjectId;
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.REMOTE_RESOURCE;
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)
*/
@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;
String source=sourcePath;
String destination=destinationPath;
@ -81,7 +81,7 @@ public class LinkOperator extends Link {
String oldir=(String)fold.get("dir");
if(logger.isDebugEnabled())
logger.debug("old dir found "+oldir);
if((oldir.equalsIgnoreCase(((MyFile)resource).getRemoteDir()))){
if((oldir.equalsIgnoreCase(((RequestObject)resource).getRemoteDir()))){
ObjectId oldId=(ObjectId) fold.getId();
if(!replace){
return oldId.toString();

View File

@ -4,7 +4,7 @@
package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
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.OPERATION;
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)
*/
@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();
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
// if((resource.getLocalPath()!= null) && (!resource.getLocalPath().isEmpty())){

View File

@ -9,7 +9,7 @@ import java.util.List;
import org.bson.types.ObjectId;
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.service.operation.Monitor;
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)
*/
@Override
public List<String> execute(MongoIOManager mongoPrimaryInstance, MyFile resource, String sourcePath,
String destinationPath, MemoryType memoryType) throws UnknownHostException {
public List<String> execute(MongoIOManager mongoPrimaryInstance, RequestObject resource, String sourcePath,
String destinationPath, MemoryType memoryType) throws UnknownHostException {
String source=sourcePath;
source = appendFileSeparator(source);
String parentFolder=extractParent(source);

View File

@ -7,7 +7,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
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.service.operation.Monitor;
import org.gcube.contentmanagement.blobstorage.service.operation.Move;
@ -53,12 +53,12 @@ public class MoveOperator extends Move {
*/
@Override
// 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 destination=destinationPath;
resource.setLocalPath(sourcePath);
String dir=((MyFile)resource).getRemoteDir();
String name=((MyFile)resource).getName();
String dir=((RequestObject)resource).getRemoteDir();
String name=((RequestObject)resource).getName();
String destinationId=null;
String sourceId=null;
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
mongoPrimaryInstance.buildDirTree(mongoPrimaryInstance.getMetaDataCollection(mongoPrimaryInstance.getConnectionDB( MongoOperationManager.getPrimaryCollectionName(), true)), dir);
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 ");
mongoPrimaryInstance.printObject(sourcePathMetaCollection);
//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();
if(op == null){
op=resource.getOperationDefinition().getOperation();

View File

@ -9,7 +9,7 @@ import java.util.Objects;
import org.bson.types.ObjectId;
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.OPERATION;
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
@ -38,7 +38,7 @@ public class SoftCopyOperator extends SoftCopy {
Logger logger=LoggerFactory.getLogger(SoftCopyOperator.class);
private MemoryType memoryType;
private MongoIOManager mongoPrimaryInstance;
private MyFile resource;
private RequestObject resource;
/**
* @param server
* @param user
@ -56,7 +56,7 @@ public class SoftCopyOperator extends SoftCopy {
}
@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 {
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
LOCAL_RESOURCE localResourceIdentifier=resource.getOperation().getLocalResource();
@ -71,9 +71,9 @@ public class SoftCopyOperator extends SoftCopy {
else
destination=destinationPath;
if(resource!=null){
String dir=((MyFile)resource).getRemoteDir();
String name=((MyFile)resource).getName();
setMemoryType(((MyFile)resource).getGcubeMemoryType());
String dir=((RequestObject)resource).getRemoteDir();
String name=((RequestObject)resource).getName();
setMemoryType(((RequestObject)resource).getGcubeMemoryType());
}
setMongoPrimaryInstance(mongoPrimaryInstance);
ObjectId mapId=null;
@ -162,7 +162,7 @@ public class SoftCopyOperator extends SoftCopy {
return destObject.getId().toString();
}
private String fillGenericDestinationFields(MyFile resource, ObjectId souceId) {
private String fillGenericDestinationFields(RequestObject resource, ObjectId souceId) {
String destination;
destination=resource.getRootPath()+souceId;
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 {
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?)
if((dir !=null && !dir.isEmpty()) && (bucket !=null && !bucket.isEmpty())){
getMongoPrimaryInstance().buildDirTree(getMongoPrimaryInstance().getMetaDataCollection(null), dir);
}
// create new map object
id= createNewObjectMap(metaCollectionInstance, (MyFile)resource, sourceObject, sourceId);
id= createNewObjectMap(metaCollectionInstance, (RequestObject)resource, sourceObject, sourceId);
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();
// set type of object
DBObject document=new BasicDBObject("type", "map");
@ -207,7 +207,7 @@ public class SoftCopyOperator extends SoftCopy {
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");
document.put("filename", destination);
document.put("name", resource.getName());
@ -227,8 +227,8 @@ public class SoftCopyOperator extends SoftCopy {
return fillCommonfields(document, resource, sourceObject, metaCollectionInstance, md5);
}
private DBObject fillCommonfields(DBObject document, MyFile resource, GridFSDBFile sourceObject, DBCollection metaCollectionInstance, String md5) {
document.put("mimetype", ((MyFile)resource).getMimeType());
private DBObject fillCommonfields(DBObject document, RequestObject resource, GridFSDBFile sourceObject, DBCollection metaCollectionInstance, String md5) {
document.put("mimetype", ((RequestObject)resource).getMimeType());
document.put("creationTime", DateUtils.now("dd MM yyyy 'at' hh:mm:ss z"));
document.put("md5", md5);
document.put("length", sourceObject.getLength());
@ -339,11 +339,11 @@ public class SoftCopyOperator extends SoftCopy {
this.mongoPrimaryInstance = mongoPrimaryInstance;
}
public MyFile getResource() {
public RequestObject getResource() {
return resource;
}
public void setResource(MyFile resource) {
public void setResource(RequestObject resource) {
this.resource = resource;
}

View File

@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
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.OPERATION;
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)
*/
@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;
OperationDefinition op=resource.getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=resource.getOperation().getRemoteResource();
@ -58,8 +58,8 @@ public class UnlockOperator extends Unlock {
// mongoPrimaryInstance.close();
// resource.setOperation(op);
// }
String dir=((MyFile)resource).getRemoteDir();
String name=((MyFile)resource).getName();
String dir=((RequestObject)resource).getRemoteDir();
String name=((RequestObject)resource).getName();
String path=getBucket();
if(logger.isDebugEnabled())
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");
if(logger.isDebugEnabled())
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");
//check if the od file is locked
if((lock !=null) && (!lock.isEmpty())){
@ -76,14 +76,14 @@ public class UnlockOperator extends Unlock {
if(lck.equalsIgnoreCase(key4unlock)){
f.put("lock", null);
f.put("timestamp", null);
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (MyFile)resource, OPERATION.UNLOCK);
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (RequestObject)resource, OPERATION.UNLOCK);
f.save();
}else{
mongoPrimaryInstance.close();
throw new IllegalAccessError("bad key for unlock");
}
}else{
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (MyFile)resource, OPERATION.UNLOCK);
mongoPrimaryInstance.updateCommonFields((GridFSFile)f, (RequestObject)resource, OPERATION.UNLOCK);
f.save();
}
}else{

View File

@ -5,7 +5,7 @@ package org.gcube.contentmanagement.blobstorage.transport.backend.operation;
import java.io.IOException;
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.REMOTE_RESOURCE;
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)
*/
@Override
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, MyFile resource, String bucket, boolean replace) throws IOException {
OperationDefinition op=((MyFile)resource).getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=((MyFile)resource).getOperation().getRemoteResource();
public String execute(MongoIOManager mongoPrimaryInstance, MongoIOManager mongoSecondaryInstance, RequestObject resource, String bucket, boolean replace) throws IOException {
OperationDefinition op=((RequestObject)resource).getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=((RequestObject)resource).getOperation().getRemoteResource();
logger.info("MongoClient put method: "+op.toString());
String dir=((MyFile)resource).getRemoteDir();
String name=((MyFile)resource).getName();
String dir=((RequestObject)resource).getRemoteDir();
String name=((RequestObject)resource).getName();
Object id=null;
ObjectId oldId=null;
// 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 {
OperationDefinition op=((MyFile)resource).getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=((MyFile)resource).getOperation().getRemoteResource();
OperationDefinition op=((RequestObject)resource).getOperationDefinition();
REMOTE_RESOURCE remoteResourceIdentifier=((RequestObject)resource).getOperation().getRemoteResource();
logger.info("MongoClient put method: "+op.toString());
String dir=((MyFile)resource).getRemoteDir();
String name=((MyFile)resource).getName();
String dir=((RequestObject)resource).getRemoteDir();
String name=((RequestObject)resource).getName();
ObjectId id=null;
ObjectId oldId=null;
// id of the remote file if present