git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@171499 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cb861b5bb3
commit
107a40171d
|
@ -2,9 +2,11 @@ package org.gcube.common.storagehub.client.dsl;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||
import org.gcube.common.storagehub.model.acls.ACL;
|
||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
|
||||
public class FolderContainer extends ItemContainer<FolderItem>{
|
||||
|
@ -48,5 +50,14 @@ public class FolderContainer extends ItemContainer<FolderItem>{
|
|||
return new ListResolver(excludes -> itemclient.findChildrenByNamePattern(itemId, namePattern , excludes), itemclient);
|
||||
}
|
||||
|
||||
public FolderContainer share(Set<String> users, AccessType accessType) throws Exception {
|
||||
itemclient.shareFolder(this.itemId, users, accessType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FolderContainer unshare(Set<String> users) throws Exception {
|
||||
itemclient.unshareFolder(this.itemId, users);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,4 +29,8 @@ public class StorageHubClient {
|
|||
return new FolderContainer(itemclient, wsClient.getVreFolder());
|
||||
}
|
||||
|
||||
public FolderContainer openTrash() {
|
||||
return new FolderContainer(itemclient, wsClient.getTrashFolder());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.io.FileOutputStream;
|
|||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -49,7 +48,9 @@ public class TestCall {
|
|||
@BeforeClass
|
||||
public static void setUp(){
|
||||
|
||||
SecurityTokenProvider.instance.set("595ca591-9921-423c-bfca-f8be19f05882-98187548");
|
||||
SecurityTokenProvider.instance.set("0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548");
|
||||
//token costantino 9ca79556-54b0-4bbf-ab0f-151ae326f4cf-98187548
|
||||
//SecurityTokenProvider.instance.set("9ca79556-54b0-4bbf-ab0f-151ae326f4cf-98187548");
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
}
|
||||
|
||||
|
@ -77,8 +78,8 @@ public class TestCall {
|
|||
|
||||
WorkspaceManagerClient client = AbstractPlugin.workspace().build();
|
||||
Item ws = client.getWorkspace();
|
||||
String id = itemclient.createFolder(ws.getId(), "ok3SharingTest", "shared folder for test SHM");
|
||||
String sharedId = itemclient.shareFolder(id, new HashSet<String>(Arrays.asList("giancarlo.panichi", "costantino.perciante")), AccessType.WRITE_OWNER);
|
||||
String id = itemclient.createFolder(ws.getId(), "ok6SharingTest", "shared folder for test SHM");
|
||||
String sharedId = itemclient.shareFolder(id, new HashSet<String>(Arrays.asList("giancarlo.panichi")), AccessType.WRITE_OWNER);
|
||||
itemclient.uploadFile(new FileInputStream("/home/lucio/Downloads/upload.pdf"), sharedId, "sharedFile.pdf" , "shared file in a shared folder");
|
||||
|
||||
}
|
||||
|
@ -87,13 +88,13 @@ public class TestCall {
|
|||
public void shareAnAlreadySharedFolder() {
|
||||
|
||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
itemclient.shareFolder("ce7b9809-fcd7-4dc7-8cd8-9ead30eb816b", new HashSet<>(Arrays.asList("massimiliano.assante")), AccessType.READ_ONLY);
|
||||
itemclient.shareFolder("86e8472a-6f66-4608-9d70-20102c9172ce", new HashSet<>(Arrays.asList("costantino.perciante")), AccessType.READ_ONLY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unshareFolder() throws Exception{
|
||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
itemclient.unshareFolder("394ed3a0-a3fd-4ff4-99be-1267465f1db9", Collections.emptySet());
|
||||
itemclient.unshareFolder("86e8472a-6f66-4608-9d70-20102c9172ce", new HashSet<>(Arrays.asList("giancarlo.panichi")));
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ public class TestCall {
|
|||
@Test
|
||||
public void delete() throws Exception{
|
||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
itemclient.delete("b3e52167-989a-4f42-a745-0388cf84688c");
|
||||
itemclient.delete("7af3d5cb-5e74-4a80-be81-acb2fec74cd9");
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue