From 3627023be826ce6d793b0889242cdb2df1f4714b Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Fri, 25 May 2018 16:05:44 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@167781 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/proxies/DefaultItemManager.java | 20 ++++++++++++++ .../client/proxies/ItemManagerClient.java | 3 +++ .../org/gcube/data/access/fs/TestCall.java | 26 +++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultItemManager.java b/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultItemManager.java index b07a07c..f1961fa 100644 --- a/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultItemManager.java +++ b/src/main/java/org/gcube/common/storagehub/client/proxies/DefaultItemManager.java @@ -14,11 +14,13 @@ 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.acls.ACL; 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; +import org.gcube.common.storagehub.model.types.ACLList; import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.glassfish.jersey.media.multipart.MultiPartFeature; @@ -206,5 +208,23 @@ public class DefaultItemManager implements ItemManagerClient { throw new RuntimeException(e); } } + + @Override + public List getACL(String id) { + Call call = new Call() { + @Override + public ACLList call(WebTarget manager) throws Exception { + WebTarget myManager = manager.path(id).path("acls"); + Invocation.Builder builder = myManager.request(MediaType.APPLICATION_JSON); + ACLList response = builder.get(ACLList.class); + return response; + } + }; + try { + return delegate.make(call).getAcls(); + }catch(Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/src/main/java/org/gcube/common/storagehub/client/proxies/ItemManagerClient.java b/src/main/java/org/gcube/common/storagehub/client/proxies/ItemManagerClient.java index 44ace2f..ef42b95 100644 --- a/src/main/java/org/gcube/common/storagehub/client/proxies/ItemManagerClient.java +++ b/src/main/java/org/gcube/common/storagehub/client/proxies/ItemManagerClient.java @@ -4,6 +4,7 @@ import java.io.InputStream; import java.util.List; import org.gcube.common.storagehub.client.StreamDescriptor; +import org.gcube.common.storagehub.model.acls.ACL; import org.gcube.common.storagehub.model.items.AbstractFileItem; import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.Item; @@ -29,5 +30,7 @@ public interface ItemManagerClient { T uploadFile(InputStream stream, String parentId, String fileName, String description); FolderItem createFolder(String parentId, String name, String description); + + List getACL(String id); } diff --git a/src/test/java/org/gcube/data/access/fs/TestCall.java b/src/test/java/org/gcube/data/access/fs/TestCall.java index 45d7a32..69accb4 100644 --- a/src/test/java/org/gcube/data/access/fs/TestCall.java +++ b/src/test/java/org/gcube/data/access/fs/TestCall.java @@ -14,6 +14,7 @@ import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.proxies.ItemManagerClient; import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient; import org.gcube.common.storagehub.model.Paths; +import org.gcube.common.storagehub.model.acls.ACL; import org.gcube.common.storagehub.model.expressions.GenericSearchableItem; import org.gcube.common.storagehub.model.expressions.OrderField; import org.gcube.common.storagehub.model.expressions.OrderField.MODE; @@ -67,6 +68,22 @@ public class TestCall { System.in.read(); } + + @Test + public void getACL() throws Exception{ + final ItemManagerClient client = AbstractPlugin.item().build(); + try { + List acls = client.getACL("790e4c52-fbca-48e9-b267-67ea2ce708c0"); + + System.out.println("items are "+acls.size()); + + + for (ACL acl: acls) + System.out.println(acl.getPricipal()+ " "+acl.getAccessTypes()); + }catch(Exception e) { + e.printStackTrace(); + } + } @Test public void download() throws Exception{ @@ -107,10 +124,14 @@ public class TestCall { @Test public void createFolder() { + long start= System.currentTimeMillis(); ItemManagerClient itemclient = AbstractPlugin.item().build(); WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build(); - itemclient.createFolder(wsclient.getWorkspace().getId(),"terzo tentativo","secondo tentativo"); - + String id = wsclient.getWorkspace("hl:accounting", "jcr:content").getId(); + System.out.println("getting the WS id took "+(System.currentTimeMillis()-start)); + + itemclient.createFolder(id,"quinto tentativo","5 tentativo"); + System.out.println("creating folder took total "+(System.currentTimeMillis()-start)); } @Test @@ -121,6 +142,7 @@ public class TestCall { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2015); */ + WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build(); String path = wsclient.getVreFolder("hl:accounting").getPath(); System.out.println("path is "+path);