git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@173247 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8886f1c88c
commit
0ebc3de5f8
|
@ -1,9 +1,11 @@
|
|||
package org.gcube.common.storagehub.client.dsl;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.service.Version;
|
||||
|
||||
public class FileContainer extends ItemContainer<AbstractFileItem> {
|
||||
|
||||
|
@ -23,6 +25,10 @@ public class FileContainer extends ItemContainer<AbstractFileItem> {
|
|||
return itemclient.getPublickLink(this.itemId);
|
||||
}
|
||||
|
||||
public List<Version> getVersions() {
|
||||
return itemclient.getFileVersions(this.itemId);
|
||||
}
|
||||
|
||||
public FileContainer copy(FolderContainer folder, String newFileName) {
|
||||
return new FileContainer(itemclient, itemclient.copy(this.itemId, folder.get().getId(), newFileName));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
|||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.service.ItemList;
|
||||
import org.gcube.common.storagehub.model.service.ItemWrapper;
|
||||
import org.gcube.common.storagehub.model.service.Version;
|
||||
import org.gcube.common.storagehub.model.service.VersionList;
|
||||
import org.gcube.common.storagehub.model.types.ACLList;
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
|
@ -207,6 +209,34 @@ public class DefaultItemManager implements ItemManagerClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Version> getFileVersions(String id) {
|
||||
Call<GXWebTargetAdapterRequest, VersionList> call = new Call<GXWebTargetAdapterRequest, VersionList>() {
|
||||
@Override
|
||||
public VersionList call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("versions");
|
||||
|
||||
GXInboundResponse response = myManager.get();
|
||||
|
||||
if (response.isErrorResponse()) {
|
||||
if (response.hasException())
|
||||
throw response.getException();
|
||||
else
|
||||
throw new BackendGenericError();
|
||||
}
|
||||
|
||||
VersionList versions = response.getSource().readEntity(VersionList.class);
|
||||
|
||||
return versions;
|
||||
}
|
||||
};
|
||||
try {
|
||||
VersionList result = delegate.make(call);
|
||||
return result.getItemlist();
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item get(String id, String... excludeNodes) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.common.storagehub.client.StreamDescriptor;
|
|||
import org.gcube.common.storagehub.model.acls.ACL;
|
||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.service.Version;
|
||||
|
||||
|
||||
|
||||
|
@ -58,6 +59,6 @@ public interface ItemManagerClient {
|
|||
|
||||
String rename(String id, String newName);
|
||||
|
||||
|
||||
List<Version> getFileVersions(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,12 @@ public class Items {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void renameFile() throws Exception{
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
shc.open("8822478a-4fd3-41d5-87de-9ff161d0935e").asItem().rename("renamed");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
|
@ -74,7 +80,7 @@ public class Items {
|
|||
public void download() throws Exception {
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
|
||||
FolderContainer openResolver = shc.open("ad8ba805-bcc5-4d0e-90c9-53216970b3e6").asFolder();
|
||||
FolderContainer openResolver = shc.open("894d23bf-e2e9-42b6-a781-b99bb18119c8").asFolder();
|
||||
|
||||
StreamDescriptor streamDescr = openResolver.download();
|
||||
|
||||
|
|
Loading…
Reference in New Issue