git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@171936 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c83f71498e
commit
487a0009d0
|
@ -49,6 +49,14 @@ public abstract class ItemContainer<I extends Item> {
|
||||||
itemclient.delete(this.itemId);
|
itemclient.delete(this.itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rename(String newName) {
|
||||||
|
//itemclient.rename(this.itemId, newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(FolderContainer folder) {
|
||||||
|
itemclient.move(this.itemId, folder.get().getId());
|
||||||
|
}
|
||||||
|
|
||||||
public FolderContainer getRootSharedFolder() {
|
public FolderContainer getRootSharedFolder() {
|
||||||
return new FolderContainer(itemclient, (FolderItem)itemclient.getRootSharedFolder(this.itemId));
|
return new FolderContainer(itemclient, (FolderItem)itemclient.getRootSharedFolder(this.itemId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,7 +509,8 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError("error response returned from server "+response.getHTTPCode());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -611,5 +612,36 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String move(String id, String destinationFolderId) {
|
||||||
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
GXWebTargetAdapterRequest myManager = manager.path(id)
|
||||||
|
.path("move");
|
||||||
|
|
||||||
|
MultivaluedMap<String, String> formData = new MultivaluedHashMap<String, String>();
|
||||||
|
formData.add("destinationId", destinationFolderId);
|
||||||
|
|
||||||
|
|
||||||
|
GXInboundResponse response = myManager.put(Entity.form(formData));
|
||||||
|
|
||||||
|
if (response.isErrorResponse()) {
|
||||||
|
if (response.hasException())
|
||||||
|
throw response.getException();
|
||||||
|
else
|
||||||
|
throw new BackendGenericError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.getSource().readEntity(String.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ public interface ItemManagerClient {
|
||||||
|
|
||||||
String unshareFolder(String id, Set<String> users);
|
String unshareFolder(String id, Set<String> users);
|
||||||
|
|
||||||
|
String move(String id, String destinationFolderId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class Items {
|
||||||
|
|
||||||
FileContainer file = null;
|
FileContainer file = null;
|
||||||
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/TatyanaSondre.jpg"))){
|
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/TatyanaSondre.jpg"))){
|
||||||
file = shc.getWSRoot().uploadFile(is, "TatyanaSondre3.jpg", "descr");
|
file = shc.getWSRoot().uploadFile(is, "TatyanaSondre5.jpg", "descr");
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -74,9 +74,9 @@ public class Items {
|
||||||
public void download() throws Exception {
|
public void download() throws Exception {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
FolderContainer openResolver = shc.open("5cf82ba3-53b9-4352-b37a-c4a94800eaec").asFolder();
|
FolderContainer openResolver = shc.open("ad8ba805-bcc5-4d0e-90c9-53216970b3e6").asFolder();
|
||||||
|
|
||||||
StreamDescriptor streamDescr = openResolver.findByName("stat_algo.project").getContainers().get(0).download();
|
StreamDescriptor streamDescr = openResolver.download();
|
||||||
|
|
||||||
|
|
||||||
File output = Files.createTempFile("down", streamDescr.getFileName()).toFile();
|
File output = Files.createTempFile("down", streamDescr.getFileName()).toFile();
|
||||||
|
@ -108,8 +108,8 @@ public class Items {
|
||||||
|
|
||||||
String afi = null;
|
String afi = null;
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/test7z.7z"))){
|
try(InputStream is = new FileInputStream(new File("/tmp/down724121986692880606my new folder.zip"))){
|
||||||
shc.getWSRoot().uploadArchive(is, "test7z");
|
shc.getWSRoot().uploadArchive(is, "testUpload2");
|
||||||
|
|
||||||
System.out.println(afi);
|
System.out.println(afi);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -137,8 +137,12 @@ public class Items {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void delete() throws Exception{
|
public void delete() throws Exception{
|
||||||
|
try {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
shc.open("8dc6fca2-f0f5-4813-b854-f12e414e3a28").asFile().delete();
|
shc.open("733a8235-e539-46c6-875d-3038579d4c6a").asFile().delete();
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue