git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@169019 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0d88de7118
commit
8b64aa678a
|
@ -49,6 +49,30 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Item> T retieveItemByPath(String relativePath, String... excludeNodes) {
|
||||
Call<WebTarget, ItemWrapper<T>> call = new Call<WebTarget, ItemWrapper<T>>() {
|
||||
@Override
|
||||
public ItemWrapper<T> call(WebTarget manager) throws Exception {
|
||||
WebTarget myManager = manager;
|
||||
if (excludeNodes !=null && excludeNodes.length>0)
|
||||
myManager = myManager.queryParam("exclude",excludeNodes);
|
||||
|
||||
myManager = manager.queryParam("relPath", relativePath);
|
||||
Invocation.Builder builder = myManager.request(MediaType.APPLICATION_JSON);
|
||||
ItemWrapper<T> response = builder.get(ItemWrapper.class);
|
||||
System.out.println(manager.getUri().toString());
|
||||
return response;
|
||||
}
|
||||
};
|
||||
try {
|
||||
ItemWrapper<T> result = delegate.make(call);
|
||||
return result.getItem();
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Item> getVreFolders(String ... excludeNodes) {
|
||||
Call<WebTarget, ItemList> call = new Call<WebTarget, ItemList>() {
|
||||
|
@ -184,5 +208,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ public interface WorkspaceManagerClient {
|
|||
|
||||
<T extends Item> T getWorkspace(String ... excludeNodes);
|
||||
|
||||
<T extends Item> T retieveItemByPath(String relativePath, String ... excludeNodes);
|
||||
|
||||
List<? extends Item> getVreFolders(String ... excludeNodes);
|
||||
|
||||
List<? extends Item> getVreFolders(int start, int limit, String ... excludeNodes);
|
||||
|
|
|
@ -25,8 +25,8 @@ public class Items {
|
|||
public void uploadFile() {
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
|
||||
try (InputStream is = new FileInputStream(new File("/home/lucio/Downloads/bonifico ferrara anricipo.pdf"))){
|
||||
AbstractFileItem afi = shc.get().open("14d498da-eea1-4fb7-8590-9ce91aaba542").uploadFile(is, "bonificopdf1", "descr");
|
||||
try (InputStream is = new FileInputStream(new File("/home/lucio/Downloads/Metodo-Calisthenics.pdf"))){
|
||||
AbstractFileItem afi = shc.get().open("14d498da-eea1-4fb7-8590-9ce91aaba542").uploadFile(is, "testVersion", "descr");
|
||||
System.out.println(afi.getId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -36,8 +36,8 @@ public class TestCall {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp(){
|
||||
SecurityTokenProvider.instance.set("595ca591-9921-423c-bfca-f8be19f05882-98187548");
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
SecurityTokenProvider.instance.set("8effc529-44ec-4895-b727-ed0dc14ad113-843339462");
|
||||
ScopeProvider.instance.set("/d4science.research-infrastructures.eu");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,6 +45,7 @@ public class TestCall {
|
|||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
WorkspaceManagerClient client = AbstractPlugin.workspace().build();
|
||||
Item ws = client.getWorkspace();
|
||||
System.out.println("ws id is "+ws.getId());
|
||||
List<? extends Item> items = itemclient.getChildren(ws.getId(),10, 5, "hl:accounting", "jcr:content");
|
||||
List<? extends Item> Vreitems = client.getVreFolders("hl:accounting");
|
||||
List<? extends Item> VreitemsPaged = client.getVreFolders(5,5, "hl:accounting");
|
||||
|
@ -139,7 +140,7 @@ public class TestCall {
|
|||
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");
|
||||
itemclient.createFolder(id,"sesto tentativo","6 tentativo");
|
||||
System.out.println("creating folder took total "+(System.currentTimeMillis()-start));
|
||||
}
|
||||
|
||||
|
@ -153,9 +154,9 @@ public class TestCall {
|
|||
*/
|
||||
|
||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||
String path = wsclient.getVreFolder("hl:accounting").getPath();
|
||||
System.out.println("path is "+path);
|
||||
query.setExpression(new ISDescendant(Paths.getPath("/Home/lucio.lelii/Workspace/MySpecialFolders/gcube-devNext-NextNext")));
|
||||
//String path = wsclient.getVreFolder("hl:accounting").getPath();
|
||||
//System.out.println("path is "+path);
|
||||
query.setExpression(new ISDescendant(Paths.getPath("/Home/massimiliano.assante/Workspace/MySpecialFolders/d4science.research-infrastructures.eu-gCubeApps-BlueBridgeProject/")));
|
||||
query.setLimit(10);
|
||||
query.setOrder(new OrderField(GenericSearchableItem.get().lastModification,MODE.DESC));
|
||||
List<? extends Item> items = wsclient.search(query, "hl:accounting", "jcr:content");
|
||||
|
|
Loading…
Reference in New Issue