2018-04-18 15:55:20 +02:00
|
|
|
package org.gcube.common.storagehub.client.dsl;
|
2018-03-29 18:19:01 +02:00
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
|
|
|
import org.gcube.common.storagehub.model.items.FolderItem;
|
|
|
|
import org.gcube.common.storagehub.model.items.Item;
|
|
|
|
|
2018-06-15 17:33:13 +02:00
|
|
|
public class FolderContainer extends ItemContainer<FolderItem>{
|
2018-03-29 18:19:01 +02:00
|
|
|
|
2018-04-18 15:55:20 +02:00
|
|
|
private FolderItem item = null;
|
|
|
|
|
2018-03-29 18:19:01 +02:00
|
|
|
// private String folderPath = null;
|
|
|
|
|
2018-06-15 17:33:13 +02:00
|
|
|
protected FolderContainer(ItemManagerClient itemclient, FolderItem item) {
|
|
|
|
super(itemclient, item);
|
2018-04-18 15:55:20 +02:00
|
|
|
}
|
|
|
|
|
2018-06-15 17:33:13 +02:00
|
|
|
protected FolderContainer(ItemManagerClient itemclient, String folderId) {
|
|
|
|
super(itemclient, folderId);
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|
2018-06-15 17:33:13 +02:00
|
|
|
|
2018-03-29 18:19:01 +02:00
|
|
|
|
|
|
|
public FolderItem get() throws Exception {
|
2018-06-15 17:33:13 +02:00
|
|
|
if (item==null) return (FolderItem)itemclient.get(itemId);
|
2018-04-18 15:55:20 +02:00
|
|
|
else return item;
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<? extends Item> list() {
|
2018-06-15 17:33:13 +02:00
|
|
|
return itemclient.getChildren(itemId);
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|
|
|
|
|
2018-06-19 11:42:57 +02:00
|
|
|
//TODO: change the return to file container
|
|
|
|
public String uploadFile(InputStream stream, String filename, String description) {
|
2018-06-15 17:33:13 +02:00
|
|
|
return itemclient.uploadFile(stream, this.itemId , filename, description);
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|
|
|
|
|
2018-06-21 12:08:31 +02:00
|
|
|
public FolderContainer newFolder(String name, String description) throws Exception {
|
|
|
|
String newFolderId = itemclient.createFolder(this.itemId, name, description);
|
|
|
|
return new FolderContainer(itemclient, newFolderId);
|
|
|
|
}
|
|
|
|
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|