git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@173304 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0ebc3de5f8
commit
7cfb84e4de
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<name>toragehub-client-library</name>
|
||||
<name>storagehub-client-library</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
|
|
@ -209,6 +209,39 @@ public class DefaultItemManager implements ItemManagerClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamDescriptor downloadSpecificVersion(String id, String version) {
|
||||
Call<GXWebTargetAdapterRequest, StreamDescriptor> call = new Call<GXWebTargetAdapterRequest, StreamDescriptor>() {
|
||||
@Override
|
||||
public StreamDescriptor call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("versions").path(version).path("download");
|
||||
|
||||
GXInboundResponse response = myManager.get();
|
||||
|
||||
if (response.isErrorResponse()) {
|
||||
if (response.hasException())
|
||||
throw response.getException();
|
||||
else
|
||||
throw new BackendGenericError();
|
||||
}
|
||||
|
||||
Response resp = response.getSource();
|
||||
|
||||
InputStream stream = resp.readEntity(InputStream.class);
|
||||
String disposition = resp.getHeaderString("Content-Disposition");
|
||||
String fileName = disposition.replaceFirst("attachment; filename = ([^/s]+)?", "$1");
|
||||
return new StreamDescriptor(stream, fileName);
|
||||
}
|
||||
};
|
||||
try {
|
||||
StreamDescriptor result = delegate.make(call);
|
||||
return result;
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Version> getFileVersions(String id) {
|
||||
Call<GXWebTargetAdapterRequest, VersionList> call = new Call<GXWebTargetAdapterRequest, VersionList>() {
|
||||
|
|
|
@ -60,5 +60,7 @@ public interface ItemManagerClient {
|
|||
String rename(String id, String newName);
|
||||
|
||||
List<Version> getFileVersions(String id);
|
||||
|
||||
StreamDescriptor downloadSpecificVersion(String id, String version);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue