git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@179295 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
355fb1f4c4
commit
16b2ab9440
|
@ -0,0 +1,2 @@
|
|||
disabled=06target
|
||||
eclipse.preferences.version=1
|
|
@ -564,7 +564,6 @@ public class DefaultItemManager implements ItemManagerClient {
|
|||
|
||||
if (response.isErrorResponse()) {
|
||||
if (response.hasException()) {
|
||||
System.out.println(response.getException().getStackTrace());
|
||||
throw response.getException();
|
||||
}else
|
||||
throw new BackendGenericError();
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package org.gcube.data.access.fs;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class AddUserToVRes {
|
||||
|
||||
|
||||
List<String> DORNE_VRE = Arrays.asList("mister.brown",
|
||||
"jesus.santamariafernandez",
|
||||
"noah.matovu",
|
||||
"andrea.rossi",
|
||||
"francesco.mangiacrapa",
|
||||
"mister.pink",
|
||||
"kostas.kakaletris",
|
||||
"massimiliano.assante",
|
||||
"mister.white",
|
||||
"mister.blonde",
|
||||
"aureliano.gentile",
|
||||
"mister.blue",
|
||||
"mister.orange",
|
||||
"lucio.lelii");
|
||||
|
||||
List<String> PARTHENOS_VRE = Arrays.asList("francesco.mangiacrapa",
|
||||
"massimiliano.assante",
|
||||
"costantino.perciante",
|
||||
"luca.frosini",
|
||||
"pasquale.pagano",
|
||||
"alessia.bardi",
|
||||
"roberto.cirillo");
|
||||
|
||||
List<String> PRE_VRE = Arrays.asList("fabio.sinibaldi",
|
||||
"valentina.marioli",
|
||||
"statistical.manager",
|
||||
"roberto.cirillo",
|
||||
"francesco.mangiacrapa",
|
||||
"leonardo.candela",
|
||||
"costantino.perciante",
|
||||
"mariaantonietta.digirolamo",
|
||||
"gantzoulatos",
|
||||
"massimiliano.assante",
|
||||
"lucio.lelii",
|
||||
"panagiota.koltsida",
|
||||
"ngalante",
|
||||
"efthymios",
|
||||
"nikolas.laskaris",
|
||||
"andrea.dellamico",
|
||||
"gianpaolo.coro",
|
||||
"giancarlo.panichi",
|
||||
"kostas.kakaletris",
|
||||
"scarponi",
|
||||
"andrea.rossi",
|
||||
"pasquale.pagano",
|
||||
"mister.blue",
|
||||
"m.assante",
|
||||
"yannis.marketakis",
|
||||
"grsf.publisher",
|
||||
"kgiannakelos",
|
||||
"mister.pink",
|
||||
"luca.frosini",
|
||||
"dkatris",
|
||||
"paolo.fabriani",
|
||||
"mister.brown",
|
||||
"mister.white",
|
||||
"mister.orange",
|
||||
"gabriele.giammatteo");
|
||||
|
||||
@Test
|
||||
public void add() throws Exception{
|
||||
String group = "pred4s-preprod-preVRE";
|
||||
URL addGroupUrl = new URL("http://storagehub.pre.d4science.net/storagehub/workspace/groups/"+group+"?gcube-token=a6cec25b-3844-4901-83f3-95eee83319ba-980114272");
|
||||
|
||||
for (String user : PRE_VRE) {
|
||||
try {
|
||||
HttpURLConnection connection =(HttpURLConnection)addGroupUrl.openConnection();
|
||||
connection.setRequestMethod("PUT");
|
||||
StringBuilder postData = new StringBuilder();
|
||||
postData.append("userId");
|
||||
postData.append("=");
|
||||
postData.append(user);
|
||||
/*postData.append("&");
|
||||
postData.append("password");
|
||||
postData.append("=");
|
||||
postData.append("pwd"+user.hashCode());*/
|
||||
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
connection.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
|
||||
connection.setDoOutput(true);
|
||||
connection.getOutputStream().write(postDataBytes);
|
||||
Reader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
|
||||
for (int c; (c = in.read()) >= 0;)
|
||||
System.out.print((char)c);
|
||||
}catch (Exception e) {
|
||||
System.out.println("error for user "+user);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -98,19 +98,14 @@ public class Items {
|
|||
|
||||
|
||||
|
||||
@Test
|
||||
@Test(expected=UserNotAuthorizedException.class)
|
||||
public void uploadAndcopyFile() throws Exception {
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
|
||||
shc.open("15191718-d848-4b85-a748-0cf3adade042").asFolder().newFolder("shouldFail", "fail");
|
||||
/*
|
||||
FileContainer file = null;
|
||||
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/Table.java"))){
|
||||
file = shc.open("15191718-d848-4b85-a748-0cf3adade042").asFolder().uploadFile(is, "TableNew.java", "descr");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
file = shc.open("3bc977be-37f0-4518-888f-a7cb96c9be8e").asFolder().uploadFile(is, "TableNew.java", "descr");
|
||||
}
|
||||
//file.copy(shc.getWSRoot(), "firstCopy.jpg");
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.gcube.common.storagehub.model.Metadata;
|
|||
import org.gcube.common.storagehub.model.Paths;
|
||||
import org.gcube.common.storagehub.model.acls.ACL;
|
||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||
import org.gcube.common.storagehub.model.expressions.GenericSearchableItem;
|
||||
import org.gcube.common.storagehub.model.expressions.OrderField;
|
||||
import org.gcube.common.storagehub.model.expressions.SearchableItem;
|
||||
|
@ -36,7 +37,6 @@ import org.gcube.common.storagehub.model.expressions.logical.ISDescendant;
|
|||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.GCubeItem;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.items.TrashItem;
|
||||
import org.gcube.common.storagehub.model.query.Queries;
|
||||
import org.gcube.common.storagehub.model.query.Query;
|
||||
import org.glassfish.jersey.client.ClientProperties;
|
||||
|
@ -53,47 +53,14 @@ public class TestCall {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp(){
|
||||
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
SecurityTokenProvider.instance.set("7c26a682-f47b-4e6e-90e0-6d101a4314cd-980114272");
|
||||
ScopeProvider.instance.set("/pred4s");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getListByPath() throws Exception{
|
||||
|
||||
@Test(expected=UserNotAuthorizedException.class)
|
||||
public void createNotAuthorized() throws Exception{
|
||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
WorkspaceManagerClient client = AbstractPlugin.workspace().build();
|
||||
|
||||
try {
|
||||
|
||||
Item trash = client.getTrashFolder();
|
||||
|
||||
System.out.println("count: "+ itemclient.childrenCount(trash.getId(), false));
|
||||
List<? extends Item > items;
|
||||
do {
|
||||
items = itemclient.getChildren(trash.getId(), 0, 200, false);
|
||||
|
||||
for (Item item: items) {
|
||||
TrashItem ti = (TrashItem) item;
|
||||
List<? extends Item > trashChildren = itemclient.getChildren(ti.getId(), false);
|
||||
log.info(" item : {} type: {}",item.getId(), ti.getMimeType());
|
||||
for (Item child: trashChildren )
|
||||
log.info("child {} of type {}", child.getName(), child.getClass().getName());
|
||||
itemclient.delete(item.getId());
|
||||
|
||||
}
|
||||
Thread.sleep(10000);
|
||||
}while(items!=null && items.size()!=0 );
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/*List<? extends Item> items = itemclient.getChildren(ws.getId(),10, 5, "hl:accounting", "jcr:content");
|
||||
|
||||
List<? extends Item> VreitemsPaged = client.getVreFolders(5,5, "hl:accounting");
|
||||
|
||||
System.out.println("items are "+items.size());
|
||||
*/
|
||||
|
||||
|
||||
itemclient.createFolder("3bc977be-37f0-4518-888f-a7cb96c9be8e", "cannot create", "", false);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue