2018-04-18 15:55:20 +02:00
|
|
|
package org.gcube.common.storagehub.client.dsl;
|
2018-03-29 18:19:01 +02:00
|
|
|
|
2018-06-15 17:33:13 +02:00
|
|
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
2019-10-14 10:18:54 +02:00
|
|
|
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
|
2018-06-15 17:33:13 +02:00
|
|
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
2020-01-16 18:11:46 +01:00
|
|
|
import org.gcube.common.storagehub.client.proxies.UserManagerClient;
|
2018-06-15 17:33:13 +02:00
|
|
|
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
2019-03-13 18:33:58 +01:00
|
|
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
2018-06-15 17:33:13 +02:00
|
|
|
import org.gcube.common.storagehub.model.items.Item;
|
|
|
|
|
2018-03-29 18:19:01 +02:00
|
|
|
public class StorageHubClient {
|
|
|
|
|
2018-06-15 17:33:13 +02:00
|
|
|
private WorkspaceManagerClient wsClient = AbstractPlugin.workspace().build();
|
|
|
|
private ItemManagerClient itemclient = AbstractPlugin.item().build();
|
2019-10-14 10:18:54 +02:00
|
|
|
private GroupManagerClient groupClient = AbstractPlugin.groups().build();
|
2020-01-16 18:11:46 +01:00
|
|
|
private UserManagerClient userClient = AbstractPlugin.users().build();
|
2018-03-29 18:19:01 +02:00
|
|
|
|
2018-06-15 17:33:13 +02:00
|
|
|
public FolderContainer getWSRoot(){
|
|
|
|
return new FolderContainer(itemclient, wsClient.getWorkspace());
|
|
|
|
}
|
2018-03-29 18:19:01 +02:00
|
|
|
|
2018-09-20 14:52:23 +02:00
|
|
|
/* public OpenResolver open(Path relativePath) {
|
2018-06-15 17:33:13 +02:00
|
|
|
Item item = wsClient.retieveItemByPath(relativePath.toPath());
|
|
|
|
return new OpenResolver(item, itemclient);
|
2018-09-20 14:52:23 +02:00
|
|
|
}*/
|
2018-03-29 18:19:01 +02:00
|
|
|
|
2019-03-13 18:33:58 +01:00
|
|
|
public OpenResolver open(String id) throws StorageHubException{
|
2018-06-15 17:33:13 +02:00
|
|
|
Item item = itemclient.get(id);
|
|
|
|
return new OpenResolver(item, itemclient);
|
|
|
|
}
|
2020-03-05 15:19:45 +01:00
|
|
|
|
2018-09-07 17:42:04 +02:00
|
|
|
public FolderContainer openVREFolder() {
|
|
|
|
return new FolderContainer(itemclient, wsClient.getVreFolder());
|
|
|
|
}
|
2019-10-14 10:18:54 +02:00
|
|
|
|
2019-03-13 18:33:58 +01:00
|
|
|
public ListResolver getVREFolders() {
|
|
|
|
return new ListResolver((onlyType, includeHidden, excludes) -> wsClient.getVreFolders(excludes), itemclient);
|
|
|
|
}
|
|
|
|
|
2020-01-15 19:10:33 +01:00
|
|
|
public VREFolderManager getVreFolderManager(String vreTitle) {
|
|
|
|
return new VREFolderManager(wsClient, groupClient, vreTitle);
|
|
|
|
}
|
|
|
|
|
2019-10-14 10:18:54 +02:00
|
|
|
public VREFolderManager getVreFolderManager() {
|
2020-01-15 19:10:33 +01:00
|
|
|
return new VREFolderManager(wsClient, groupClient, null);
|
2019-10-14 10:18:54 +02:00
|
|
|
}
|
|
|
|
|
2018-09-18 14:54:11 +02:00
|
|
|
public FolderContainer openTrash() {
|
|
|
|
return new FolderContainer(itemclient, wsClient.getTrashFolder());
|
|
|
|
}
|
|
|
|
|
2018-09-21 15:28:19 +02:00
|
|
|
public void emptyTrash() {
|
|
|
|
wsClient.emptyTrash();
|
|
|
|
}
|
|
|
|
|
2019-07-25 17:58:24 +02:00
|
|
|
public long getTotalVolume() {
|
2019-07-25 17:47:18 +02:00
|
|
|
return wsClient.getTotalVolume();
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getTotalItemCount() {
|
|
|
|
return wsClient.getTotalItemCount();
|
|
|
|
}
|
2019-10-14 10:18:54 +02:00
|
|
|
|
2018-09-24 16:00:41 +02:00
|
|
|
public GenericItemContainer restoreThrashItem(String itemId) {
|
|
|
|
return new GenericItemContainer(itemclient, wsClient.restoreFromTrash(itemId));
|
2018-09-21 15:28:19 +02:00
|
|
|
}
|
|
|
|
|
2020-01-16 18:11:46 +01:00
|
|
|
public void createUserAccount(String userId) throws StorageHubException {
|
|
|
|
userClient.createUser(userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deleteUserAccount(String userId) throws StorageHubException {
|
|
|
|
userClient.removeUser(userId);
|
|
|
|
}
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|