This commit is contained in:
Lucio Lelii 2018-05-25 16:05:44 +00:00
parent b39174755f
commit 3627023be8
3 changed files with 47 additions and 2 deletions

View File

@ -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<ACL> getACL(String id) {
Call<WebTarget, ACLList> call = new Call<WebTarget, ACLList>() {
@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);
}
}
}

View File

@ -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 extends AbstractFileItem> T uploadFile(InputStream stream, String parentId, String fileName, String description);
FolderItem createFolder(String parentId, String name, String description);
List<ACL> getACL(String id);
}

View File

@ -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<ACL> 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);