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.StreamDescriptor;
|
|
|
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
|
|
|
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
|
|
|
import org.gcube.common.storagehub.model.items.FolderItem;
|
|
|
|
import org.gcube.common.storagehub.model.items.Item;
|
|
|
|
|
2018-04-18 15:55:20 +02:00
|
|
|
public class FolderContainer extends ItemContainer{
|
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;
|
|
|
|
|
|
|
|
protected FolderContainer(ItemManagerClient itemclient) {
|
2018-04-18 15:55:20 +02:00
|
|
|
super(itemclient);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void setItem(FolderItem item) {
|
|
|
|
this.item = item;
|
|
|
|
this.folderId = item.getId();
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void setId(String folderId) {
|
|
|
|
this.folderId = folderId;
|
|
|
|
// this.folderPath = null;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
protected void setPath(String folderPath) {
|
|
|
|
this.folderPath = folderPath;
|
|
|
|
this.folderId = null;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
public FolderItem get() throws Exception {
|
2018-04-18 15:55:20 +02:00
|
|
|
if (item==null) return (FolderItem)itemclient.get(folderId);
|
|
|
|
else return item;
|
2018-03-29 18:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<? extends Item> list() {
|
|
|
|
return itemclient.getChildren(folderId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public <T extends AbstractFileItem> T uploadFile(InputStream stream, String filename, String description) {
|
2018-05-14 16:14:52 +02:00
|
|
|
|
2018-03-29 18:19:01 +02:00
|
|
|
return itemclient.uploadFile(stream, this.folderId , filename, description);
|
|
|
|
}
|
|
|
|
|
|
|
|
public StreamDescriptor download(InputStream stream) {
|
|
|
|
return itemclient.download(this.folderId);
|
|
|
|
}
|
|
|
|
}
|