2018-10-02 12:05:43 +02:00
|
|
|
package org.gcube.contentmanagement.blobstorage.service.impl;
|
|
|
|
|
|
|
|
import org.bson.types.ObjectId;
|
2020-12-22 17:57:44 +01:00
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
2018-10-02 12:05:43 +02:00
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.OperationDefinition.REMOTE_RESOURCE;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manage operation results of String type
|
|
|
|
* @author Roberto Cirillo (ISTI-CNR)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class RemoteResourceDestination extends Resource{
|
|
|
|
|
2020-12-22 17:57:44 +01:00
|
|
|
public RemoteResourceDestination(RequestObject file, ServiceEngine engine) {
|
2018-10-02 12:05:43 +02:00
|
|
|
super(file, engine);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param remoteDestination it can be a remote path or an id
|
|
|
|
* @return
|
|
|
|
* @throws RemoteBackendException
|
|
|
|
*/
|
|
|
|
public String to(String remoteDestination) throws RemoteBackendException{
|
|
|
|
logger.info("file gCube parameter before: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
|
|
|
|
file = setGenericProperties(engine.getContext(), engine.owner, remoteDestination, "remote");
|
|
|
|
file.setRemotePath(remoteDestination);
|
|
|
|
file.setOwner(engine.owner);
|
|
|
|
setMyFile(file);
|
|
|
|
if((remoteDestination != null) &&(ObjectId.isValid(remoteDestination))){
|
|
|
|
getMyFile().setRemoteResource(REMOTE_RESOURCE.ID);
|
|
|
|
getMyFile().setId2(remoteDestination);
|
|
|
|
}else{
|
|
|
|
getMyFile().setRemoteResource(REMOTE_RESOURCE.PATH);
|
|
|
|
}
|
|
|
|
// setMyFile(file);
|
|
|
|
engine.service.setResource(getMyFile());
|
|
|
|
String bucketName=null;
|
|
|
|
logger.info("file gCube parameter after: "+file.getGcubeAccessType()+" "+file.getGcubeScope());
|
|
|
|
bucketName=getRemoteObject(getMyFile(),engine.primaryBackend,engine.volatileBackend).toString();
|
|
|
|
return bucketName;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|