git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@167718 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4abf8a5508
commit
b39174755f
|
@ -7,12 +7,15 @@ import javax.ws.rs.client.Entity;
|
|||
import javax.ws.rs.client.Invocation;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.common.clients.Call;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.service.ItemList;
|
||||
import org.gcube.common.storagehub.model.service.ItemWrapper;
|
||||
|
@ -159,6 +162,29 @@ public class DefaultItemManager implements ItemManagerClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FolderItem createFolder(String parentId, String name, String description) {
|
||||
Call<WebTarget, ItemWrapper<FolderItem>> call = new Call<WebTarget, ItemWrapper<FolderItem>>() {
|
||||
@Override
|
||||
public ItemWrapper<FolderItem> call(WebTarget manager) throws Exception {
|
||||
WebTarget myManager = manager.path(parentId)
|
||||
.path("create").path("FOLDER").queryParam("name", name).queryParam("description", description);
|
||||
Invocation.Builder builder = myManager.request();
|
||||
|
||||
MultivaluedMap<String, String> formData = new MultivaluedHashMap<String, String>();
|
||||
formData.add("name", name);
|
||||
formData.add("description", description);
|
||||
ItemWrapper<FolderItem> response = builder.post(Entity.form(formData),ItemWrapper.class);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
try {
|
||||
ItemWrapper<FolderItem> result = delegate.make(call);
|
||||
return result.getItem();
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Item> getAnchestors(String id, String... excludeNodes) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
|
||||
|
||||
|
@ -26,5 +27,7 @@ public interface ItemManagerClient {
|
|||
StreamDescriptor download(String id);
|
||||
|
||||
<T extends AbstractFileItem> T uploadFile(InputStream stream, String parentId, String fileName, String description);
|
||||
|
||||
FolderItem createFolder(String parentId, String name, String description);
|
||||
|
||||
}
|
||||
|
|
|
@ -58,10 +58,13 @@ public class TestCall {
|
|||
@Test
|
||||
public void getById() throws Exception{
|
||||
final ItemManagerClient client = AbstractPlugin.item().build();
|
||||
List<? extends Item> items = client.getChildren("07cd8d55-a35b-4445-9680-c98f158c55de",10, 5, "hl:accounting", "jcr:content");
|
||||
|
||||
List<? extends Item> items = client.getAnchestors("29b417e2-dc2f-419a-be0b-7f49e76c9d7c", "hl:accounting", "jcr:content");
|
||||
|
||||
System.out.println("items are "+items.size());
|
||||
|
||||
for (Item item: items)
|
||||
System.out.println(item.getName()+ " "+item.getPath());
|
||||
|
||||
System.in.read();
|
||||
}
|
||||
|
||||
|
@ -102,6 +105,14 @@ public class TestCall {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createFolder() {
|
||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||
itemclient.createFolder(wsclient.getWorkspace().getId(),"terzo tentativo","secondo tentativo");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void search() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue