git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@181326 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f9c211f55a
commit
ed2ef1de33
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
<version>1.0.4-SNAPSHOT</version>
|
<version>1.0.5-SNAPSHOT</version>
|
||||||
<name>storagehub-client-library</name>
|
<name>storagehub-client-library</name>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -41,6 +41,16 @@ public class StorageHubClient {
|
||||||
wsClient.emptyTrash();
|
wsClient.emptyTrash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getTotalVolume() {
|
||||||
|
return wsClient.getTotalVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalItemCount() {
|
||||||
|
return wsClient.getTotalItemCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GenericItemContainer restoreThrashItem(String itemId) {
|
public GenericItemContainer restoreThrashItem(String itemId) {
|
||||||
return new GenericItemContainer(itemclient, wsClient.restoreFromTrash(itemId));
|
return new GenericItemContainer(itemclient, wsClient.restoreFromTrash(itemId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTotalItemCount() {
|
public long getTotalItemCount() {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
@ -370,14 +370,14 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
return delegate.make(call);
|
return Long.parseLong(delegate.make(call));
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTotalVolume() {
|
public long getTotalVolume() {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
@ -396,7 +396,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
return delegate.make(call);
|
return Long.parseLong(delegate.make(call));
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ public interface WorkspaceManagerClient {
|
||||||
|
|
||||||
void emptyTrash();
|
void emptyTrash();
|
||||||
|
|
||||||
String getTotalItemCount();
|
long getTotalItemCount();
|
||||||
|
|
||||||
String getTotalVolume();
|
long getTotalVolume();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
@ -19,6 +20,7 @@ import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
|
import org.gcube.common.storagehub.model.Metadata;
|
||||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||||
|
@ -148,6 +150,34 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changeProp() throws Exception {
|
||||||
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
|
ItemContainer item = shc.open("6399daa7-2173-4314-b4f7-2afa24eae8f8").asItem();
|
||||||
|
Metadata first = item.get().getMetadata();
|
||||||
|
first.getMap().put("lucio", "ok");
|
||||||
|
|
||||||
|
item.setMetadata(first);
|
||||||
|
|
||||||
|
Metadata second = item.get().getMetadata();
|
||||||
|
for (Entry<String, Object> entry: second.getMap().entrySet())
|
||||||
|
System.out.println(entry.getKey()+" "+entry.getValue());
|
||||||
|
|
||||||
|
|
||||||
|
second.getMap().put("lucio", null);
|
||||||
|
second.getMap().put("lelii", "0");
|
||||||
|
|
||||||
|
item.setMetadata(second);
|
||||||
|
|
||||||
|
Metadata third = item.get().getMetadata();
|
||||||
|
for (Entry<String, Object> entry: third.getMap().entrySet())
|
||||||
|
System.out.println(entry.getKey()+" "+entry.getValue());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uploadArchive() throws Exception {
|
public void uploadArchive() throws Exception {
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class TestCall {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp(){
|
public static void setUp(){
|
||||||
SecurityTokenProvider.instance.set("7c26a682-f47b-4e6e-90e0-6d101a4314cd-980114272");
|
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
||||||
ScopeProvider.instance.set("/pred4s");
|
ScopeProvider.instance.set("/gcube");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=UserNotAuthorizedException.class)
|
@Test(expected=UserNotAuthorizedException.class)
|
||||||
|
@ -281,7 +281,7 @@ public class TestCall {
|
||||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||||
//String path = wsclient.getVreFolder("hl:accounting").getPath();
|
//String path = wsclient.getVreFolder("hl:accounting").getPath();
|
||||||
//System.out.println("path is "+path);
|
//System.out.println("path is "+path);
|
||||||
query.setExpression(new ISDescendant(Paths.getPath("/Home/m.assante/Workspace/")));
|
query.setExpression(new ISDescendant(Paths.getPath("/Home/lucio.lelii/Workspace/")));
|
||||||
query.setLimit(10);
|
query.setLimit(10);
|
||||||
query.setOrder(new OrderField(GenericSearchableItem.get().title));
|
query.setOrder(new OrderField(GenericSearchableItem.get().title));
|
||||||
List<? extends Item> items = wsclient.search(query, "hl:accounting", "jcr:content");
|
List<? extends Item> items = wsclient.search(query, "hl:accounting", "jcr:content");
|
||||||
|
|
Loading…
Reference in New Issue