git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174929 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e36d718fda
commit
84ea705a9e
|
@ -11,11 +11,14 @@ import javax.ws.rs.core.Response;
|
|||
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.gcube.common.storagehub.model.Constants.*;
|
||||
|
||||
/**
|
||||
* The Class StorageHubResolver.
|
||||
|
@ -53,8 +56,9 @@ public class StorageHubResolver {
|
|||
|
||||
try{
|
||||
InnerMethodName.instance.set("resolveStorageHubPublicLink");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
|
||||
|
||||
ItemManagerClient client = AbstractPlugin.item().build();
|
||||
|
||||
//Checking mandatory parameter id
|
||||
if(id==null || id.isEmpty()){
|
||||
logger.error("Path Parameter "+STORAGE_HUB_ID+" not found");
|
||||
|
@ -62,7 +66,7 @@ public class StorageHubResolver {
|
|||
}
|
||||
|
||||
try{
|
||||
StreamDescriptor descriptor = shc.open(id).asFile().download();
|
||||
StreamDescriptor descriptor = client.resolvePublicLink(id);
|
||||
return Response
|
||||
.ok(descriptor.getStream())
|
||||
.header("content-disposition","attachment; filename = \""+descriptor.getFileName()+"\"").build();
|
||||
|
@ -71,7 +75,6 @@ public class StorageHubResolver {
|
|||
logger.error("Error on getting file with "+id, e);
|
||||
String errorMsg = "Error on getting file with hub id '"+id+"'. "+e.getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, errorMsg, StorageHubResolver.class, help);
|
||||
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
|
@ -101,7 +104,7 @@ public class StorageHubResolver {
|
|||
|
||||
try{
|
||||
InnerMethodName.instance.set("resolveStorageHubPublicLinkWithVersion");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
ItemManagerClient client = AbstractPlugin.item().build();
|
||||
|
||||
//Checking mandatory parameter id
|
||||
if(id==null || id.isEmpty()){
|
||||
|
@ -115,8 +118,8 @@ public class StorageHubResolver {
|
|||
throw ExceptionManager.badRequestException(req, "Missing mandatory parameter 'version'", StorageHubResolver.class, help);
|
||||
}
|
||||
try{
|
||||
|
||||
StreamDescriptor descriptor = shc.open(id).asFile().downloadSpecificVersion(version);
|
||||
String identifier = String.format("%s%s%s",id, versionPrefix, version);
|
||||
StreamDescriptor descriptor = client.resolvePublicLink(identifier);
|
||||
return Response
|
||||
.ok(descriptor.getStream())
|
||||
.header("content-disposition","attachment; filename = \""+descriptor.getFileName()+"\"").build();
|
||||
|
|
Loading…
Reference in New Issue